Il y a 3 ans maintenant, j'étais parvenu grâce à votre aide à mettre au point une macro pour convertir des fichiers word en pdf via le writer d'OpenOffice.
Voir le sujet ici : http://forum.openoffice.org/fr/forum/vi ... =8&t=18041
Or depuis quelques jours, j'ai installé LibreOffice Version 3.6.3.2 (Build ID: 58f22d5). J'ai récupéré ma macro en copiant tout simplement le code que voici ci dessous :
Code : Tout sélectionner
sub acConvDoc2Pdf()
dim oDoc as object
dim rep1 as string, rep2 as string
dim fic1 as string, nomFic as string
dim fic2 as string
dim cptFic as long
dim tArgs(0) as new com.sun.star.beans.PropertyValue
const TYPEDOC = "doc"
rep1 = "C:\Documents and Settings\ACGest\Mes documents\Actif\Dubus Gestion\Gestion\ComptesRendus\ConvPDF"
rep2 = "C:\Documents and Settings\ACGest\Mes documents\Actif\Dubus Gestion\Gestion\ComptesRendus\PDF"
cptFic = 0
nomFic = dir(rep1 & getPathSeparator & "*." & TYPEDOC)
if nomFic = "" then
print "Aucun fichier """ & TYPEDOC & """ dans ce répertoire"
exit sub
end if
Do While nomFic <> ""
cptFic = cptFic + 1
fic1 = rep1 & getPathSeparator & nomFic
tArgs(0).Name = "Hidden"
tArgs(0).Value = True
' msgBox("Ouverture cachée de" & chr(13) & """" & fic1 & """"
oDoc = StarDesktop.loadComponentFromURL(_
ConvertToUrl(fic1), "_blank", 0, tArgs)
fic2 = rep2 & getPathSeparator _
& left(nomFic, Len(nomFic) - 4 ) & ".pdf"
tArgs(0).Name = "FilterName"
tArgs(0).Value = "writer_pdf_Export"
oDoc.storeToURL(ConvertToUrl(fic2), tArgs)
oDoc.close(true)
' print "doc refermé"
nomFic = Dir
loop
print "Conversion terminée"
end sub
sub Main
oSourceFolder = "c:\ConvPDF"
oStoreFolder = "c:\PDF"
' This is the actual conversion loop.
nFileNum = 0
cFile = Dir$(oSourceFolder + "/*.odt")
if cFile = "" then
print "No files were found in that directory"
end if
Do While cFile <> ""
nFileNum = nFileNum + 1
cSourceName = oSourceFolder + "\" + cFile
If Not FileExists(cSourceName) Then
Msgbox(cSourceName & " was not found",0,"Error")
GoTo wasError
end if
oDoc=StarDesktop.loadComponentFromURL(cSourceName,"_blank",63,Array(MakePropertyValue("Hidden", True),))
oStoreFile = ConvertToURL(oStoreFolder + Left(cFile, Len(cFile) - 4 ) + ".pdf" )
oDoc.storeToURL(oStoreFile, Array(MakePropertyValue("FilterName", "writer_pdf_Export"),)
oDoc.dispose()
cFile = Dir$
loop
wasError:
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
Existe-t-il un didacticiel ou une documentation quelconque sur la conversion d'une macro openoffice en libreoffice ? J'ai fait des recherches sur le net mais n'ai rien trouvé.
Merci donc par avance pour le temps que vous pourrez m'accorder.

