sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,422
- Office Version
- 2016
- Platform
- Windows
I'm having trouble trying to save a Word document as a pdf file from Excel.
The Word file is embedded into the workbook and the document is extracted and populated, and then need to save it as a pdf file but within a folder selected by the user.
The part that is causing me the issue is the saving as pdf, everything else works fine - this is what I have;
It fails at the export pdf part and gives me 'Invalid procedure call or argument error 5'
Does anyone know where I am going wrong please?
The Word file is embedded into the workbook and the document is extracted and populated, and then need to save it as a pdf file but within a folder selected by the user.
The part that is causing me the issue is the saving as pdf, everything else works fine - this is what I have;
Code:
'Set doc name
dt = Format(TextBox3, "dd_mmmm_yyyy")
strFile = "1-2-1 Meeting Record - " & ComboBox1.Value & " - " & dt
'Save 121
myFile = Application.GetSaveAsFilename(InitialFileName:=strFile, FileFilter:="PDF Files (*.pdf), *.pdf", Title:="Select Folder to save")
If myFile <> "False" Then
Application.ScreenUpdating = False
'write the PDF file
myDoc.ExportAsFixedFormat OutputFileName:=myFile, _
ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, _
OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False
It fails at the export pdf part and gives me 'Invalid procedure call or argument error 5'
Does anyone know where I am going wrong please?