Excel - calc

Fermé
ironbrother - 22 nov. 2015 à 23:02
yclik Messages postés 3595 Date d'inscription vendredi 25 juillet 2014 Statut Membre Dernière intervention 26 avril 2024 - 23 nov. 2015 à 08:39
Bonjour, Je dois ce code dans Excel, enregistrez la feuille au format PDF, avec le nom de la cellule «E2», mais dans OpenOffice Calc, enregistre avec le nom vierge, pourrait me aider?

EXCEL:
Sub macrogravar()
'
' macrogravar Macro
'

'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\Caixadiario\ " & Range("e2") & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Range("H23").Select
End Sub


Openoffice calc:

sub gravarpdf
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///D:/caixadiario/ .pdf"
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
args1(2).Name = "FilterData"
dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1())


end sub



A voir également:

1 réponse

yclik Messages postés 3595 Date d'inscription vendredi 25 juillet 2014 Statut Membre Dernière intervention 26 avril 2024 1 481
23 nov. 2015 à 08:39
bonjour
une proposition

sub gravarpdf 
rem define variables 
dim document as object 
dim dispatcher as object 

dim monFichier as string
 ' nom de la feuille
 oSheet = ThisComponent.sheets.GetByName("feuille1") 
  ' Sélection de la cellue E2
  monFichier = oSheet.getCellRangeByName ("E2").getstring
  ' construction chemin  pour D:/caixadiario/ .pdf"  
  monChemin = "file:///D:/caixadiario"+monFichier+".pdf"
  
  print monChemin

rem get access to the document 
document = ThisComponent.CurrentController.Frame 
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 

dim args1(2) as new com.sun.star.beans.PropertyValue 
args1(0).Name = "URL" 
args1(0).Value = monChemin

args1(1).Name = "FilterName" 
args1(1).Value = "calc_pdf_Export" 
args1(2).Name = "FilterData" 
dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1()) 
end sub
0