Sub FazerTabelaGratuita(oEvent as Object)
Dim oDoc, oController as Object
Dim oSheet as object
Dim sName as String
oDoc = oEvent.Source
oSheet = oDoc.getCurrentController().ActiveSheet
MsgBox(oSheet.Name)
if oSheet.name = “Gratuita” then 'checar se é a planilha Gratuita
'if oSheet.Name = “Gratuita” then
Dim pVertW, pHoriW, pOuterW, pInnerW, pLiDist as Integer
Dim pRgb as Long
dIM lRow as Long
pVertW = 20
pHoriW = 20
pOuterW = 40
pInnerW = 20
pLiDist = 40
pRgb = RGB(100, 80, 255)
Dim borderLine As New com.sun.star.table.BorderLine2
Dim tb2 As New com.sun.star.table.TableBorder2
Dim rng, oLastCol, oCursor as Object
Dim oRow as Object
oSheet = ThisComponent.Sheets.getByName("Gratuita")
oLastCol = oSheet.getCellRangeByName("C1") ' Coluna C
oCursor = oSheet.createCursorByRange(oLastCol)
oCursor.GotoEndOfUsedArea(false)
lRow = oCursor.RangeAddress.EndRow
if lRow<> 0 then
lRow = lRow +1
rng = oSheet.getCellRangeByName("A10:F" & lRow)
rng.CharHeight = 12
rng.CharFontName = "Calibri"
oRow = rng.getRows()
oRow.Height = 450
oSheet.Rows.removeByIndex(lRow+1, 65500)
REM SheetCellRanges selectiopns make no sense, object (Shape e.g.) selections even less.
borderLine.Color = RGB(0, 0, 0)
' borderLine.LineStyle = 1 ' apaga a borda da tabela
borderLine.LineStyle = 0
borderLine.LineWidth = pVertW
tb2.VerticalLine = borderLine
tb2.IsVerticalLineValid = True
borderLine.LineWidth = pHoriW
tb2.HorizontalLine = borderLine
tb2.IsHorizontalLineValid = True
' borderLine.LineStyle = 1 ' apaga o interior da tabela
borderLine.LineStyle = 0
borderLine.LineDistance = pLiDist
REM With double borderlines having set different outer an inner widths.
REM there is a bug for many years now. It was never resolved, and will most likely neverba.
REM Too much code meanwhile relying on the bug - like this Sub!
REM 'Outer' is wrongly interptreted as 'Top or Right', 'Inner' as 'Left or Bottom.
REM The problem is basically the same with LineStyles 4 through 9 which create predefined double lines.
borderLine.OuterLineWidth = pOuterW
borderLine.InnerLineWidth = pInnerW
tb2.TopLine = borderLine
tb2.IsTopLineValid = True
tb2.RightLine = borderLine
tb2.IsRightLineValid = True
borderLine.OuterLineWidth = pInnerW REM A little bit counterintuitive.
borderLine.InnerLineWidth = pOuterW REM A little bit counterintuitive.
tb2.LeftLine = borderLine
tb2.IsLeftLineValid = True
tb2.BottomLine = borderLine
tb2.IsBottomLineValid = True
rng.TableBorder2 = tb2
End if
Call CriarAreaImpressaoGratuita
Else Call CriarAreaImpressaoPagaECorregedoria
End if ’ FIM DE checar se é a planilha Gratuita
End Sub