pierpo ha scritto:
oregon ha scritto:
Il file è già aperto quando avvii questo programma?
No ho eseguito il programma monitorando i processi e il processo compare dopo aver eseguito il comando
Set doc = worddoc.Documents.Open(x) '-----------open the docx
ho modificato un paio di piccole cose e ora funziona benissimo
GRAZIE
Ho fatto cosi:
Private Sub Command2_Click()
Convert_WordDoc_to_PDF "C:\PDF\prova.doc", "C:\PDF\provPDF"
End Sub
Private Sub Convert_WordDoc_to_PDF(DocPath As String, sDestsPathPDFFile As String)
'Dim worddoc As New Word.Application
Dim worddoc As Object
Set worddoc = CreateObject("Word.Application")
Dim x As String
Dim doc As Document
On Error GoTo Errhnd
x = DocPath
Set doc = worddoc.Documents.Open(x) '-----------open the docx
'now docx file is already open . so now it is time to export into PDF Format
'Specifiche:
' doc.ExportAsFixedFormat
' OutputFileName:= sDestsPathPDFFile , PATH FILE PDF
' ExportFormat:=wdExportFormatPDF, FOMATO FILE CHE DEVE CREARE
' OpenAfterExport:=True, APRE O NO IL FILE UNA VOLTA GENERATO
'OptimizeFor:=wdExportOptimizeForPrint,
'Range:= wdExportAllDocument,
'From:=1,
'To:=1,
'Item:=wdExportDocumentContent, _
' IncludeDocProps:=True,
'KeepIRM:=True,
'CreateBookmarks:= wdExportCreateNoBookmarks,
'DocStructureTags:=True,
'BitmapMissingFonts:= True,
'UseISO19005_1:=False
doc.ExportAsFixedFormat OutputFileName:= _
sDestsPathPDFFile, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False
doc.Close
Dim var As Boolean
var = KillApp("WINWORD.EXE")
Exit Sub
Errhnd:
MsgBox (Err.Description)
Set doc = Nothing
End Sub