Hi,
does anybody have any idea what am I missing in the code below:
I get this error:
Run time '5':
Invalid Procedure call or invalid argument
Here is the code:
Code:
Private Sub CommandButton1_Click()
Dim MSWord As Object
Set MSWord = CreateObject("Word.Application")
MSWord.Visible = True
Datei = "D:\WordTest.doc"
pdfName = "D:\WordTest.pdf"
MSWord.Documents.Add
With MSWord.Selection
.Font.Name = "Helvetica"
.Font.Size = 20
.Font.Color = wdColorRed
.Font.Bold = True
.Font.Italic = True
.TypeText Text:="Text"
.TypeParagraph
End With
MSWord.ActiveDocument.SaveAs Datei
MSWord.ActiveDocument.ExportAsFixedFormat OutputFileName:=pdfName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, Item:= _
wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
MSWord.ActiveDocument.Close
MSWord.Quit
Set MSWord = Nothing
End Sub
Ist it possible to open a pdf-file created by ActiveDocument.SaveAs2-Method?
Thank you.