Tenho estas macros:
>'' Salvar Arquivo Nome Célula = Sub SaveFileNameCell
Sub SaveFileNameCell
PLAN_NAME = "Plan1"
CELL_NAME = "A1"
FOLDER = "C:\Users\GILBERTO\Desktop\"
sheet = ThisComponent.Sheets.getByName(PLAN_NAME)
cell = sheet.getCellRangeByName(CELL_NAME)
path = ConvertToURL(FOLDER + cell.String + ".ods")
ThisComponent.storeToURL(path, Array()) ' NÂO RENOMEIA ARQUIVO ATIVO
' ThisComponent.storeAsURL(path, Array()) ' RENOMEIA ARQUIVO ATIVO
' Var1 = cell.String
' MsgBox "Save in: " + path
End Sub
.
>'' Salvar Arquivo Pasta Celula = Sub SaveFileFolderCel
Sub SaveFileFolderCel
' PEGAR NOME PASTA
CELL_PASTA = "A5"
FOLDER = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName(CELL_PASTA)
' PEGAR NOME ARQUIVO
CELL_ARQ = "Plan1.A8"
ARQ = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName(CELL_ARQ)
' SALVAR
path = ConvertToURL(FOLDER.String + ARQ.String + ".ods")
ThisComponent.storeToURL(path, Array())
End Sub
.
>'' Salvar Como Arquivo Pasta Celula = Sub SalvarComo
Sub SalvarComo
' PEGAR NOME PASTA
CELL_PASTA = "Parametros.F2"
FOLDER = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName(CELL_PASTA)
' PEGAR NOME ARQUIVO
CELL_ARQ = "Parametros.C38"
ARQ = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName(CELL_ARQ)
' SALVAR COMO
path = ConvertToURL(FOLDER.String + ARQ.String + ".ods")
Dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = path 'DirFile
args1(1).Name = "FilterName"
args1(1).Value = "calc8"
CreateUnoService("com.sun.star.frame.DispatchHelper") _
.executeDispatch(ThisComponent.CurrentController _
.Frame, ".uno:SaveAs", "", 0, args1())
End Sub
.
>' Salvar em PDF = Sub SavePdf "AreaPrint", "DirAndFile"
Sub SavePDF ( AreaPrint As String, DirAndFile As String )
'Exemplo: SavePdf "ImprimirFactura", "C:/Users/GILBERTO/Desktop/selection10.pdf"
Dim oController, oRange As Object
Dim Arg1(0) as new com.sun.star.beans.PropertyValue
Dim Args2(1) as new com.sun.star.beans.PropertyValue
Dim PDF_URL As String
oController = ThisComponent.CurrentController
oRange = ThisComponent.NamedRanges.getByName( AreaPrint ).ReferredCells
oController.Select(oRange)
Arg1(0).Name = "Selection" : Arg1(0).Value = oRange
Args2(0).Name = "FilterName" : Args2(0).Value = "calc_pdf_Export"
Args2(1).Name = "FilterData" : Args2(1).Value = Arg1()
PDF_URL = ConvertToURL( DirAndFile )
ThisComponent.storeToURL(Pdf_URL, args2())
End Sub