Export Docx To Pdf With Vba - Excel - Stack Overflow
Có thể bạn quan tâm
I would like to export docx file to pdf file from excel vba. Document file.docx is opened correctly. However, an error occurred while calling the method ExportAsFixedFormat: Run-time error '5': Invalid procedure call or argument. I think arguments are ok.
Next little bug: ActiveDocument.Path does not work. There is an error "Run-time error '424': Object required" Therefore I used WordApp.Documents(myFileName).ExportAsFixedFormat instead ActiveDocument.ExportAsFixedFormat.
This code is executed from file Macro.xlsm. I use Microsoft Office 2021.
Method exportasfixedformat
Dim fileNameDoc As String Dim fileNamePdf As String Dim WordApp Set WordApp = CreateObject("Word.Application") FileNameDoc = "D:\rd\file.docx" WordApp.Documents.Open FileNameDoc WordApp.Visible = True WordApp.Documents(FileNameDoc).Activate ' <- activation doesn't work fileNamePdf = "D:\rd\file.pdf" 'fileNamePdf = ActiveDocument.Path & "\" & "file.pdf" ' https://learn.microsoft.com/en-us/office/vba/api/word.document.exportasfixedformat ' here is error: Run-time error '5': Invalid procedure call or argument WordApp.Documents(myFileName).ExportAsFixedFormat OutputFileName:=fileNamePdf, _ ExportFormat:=wdExportFormatPDF, _ OpenAfterExport:=False, _ OptimizeFor:=wdExportOptimizeForPrint, _ Range:=wdExportAllDocument, _ Item:=wdExportDocumentWithMarkup, _ IncludeDocProps:=False, _ CreateBookmarks:=wdExportCreateNoBookmarks, _ BitmapMissingFonts:=True ' https://learn.microsoft.com/en-us/office/vba/api/word.document.close(method)' WordApp.Documents(myFileName).Close _ 'ActiveDocument.Close _ SaveChanges:=wdSaveChanges, _ OriginalFormat:=wdOriginalDocumentFormatAny idea for a solution?
Từ khóa » Visual Basic Excel Save As Pdf
-
Save Excel As PDF With VBA
-
Excel VBA Save As PDF: Step-By-Step Guide And 10 Code ...
-
Excel Macro To Save Sheets As PDF - Contextures
-
Excel VBA Save As (Print) To PDF
-
Excel Macro To Save As PDF (5 Suitable Examples) - ExcelDemy
-
Save File As PDF In VBA (macro)? | MrExcel Message Board
-
VBA Save Sheet As PDF - YouTube
-
Save Excel File As PDF Using VBA (Entire Workbook Or ... - YouTube
-
Save Excel As PDF With Excel VBA
-
Convert Excel To PDF Using VBA - The Only Guide You Will Need
-
How To Use Command Button To Save Active Worksheet As PDF File In ...
-
Excel VBA SaveAs "Read-only" PDF File - Stack Overflow
-
Workbook.ExportAsFixedFormat Method (Excel) - Microsoft Docs
-
Excel VBA Save As PDF: Step-By-Step Guide And 10 ... - Pinterest