Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tried to export file as PDF but had error Named argument not found excel VBA

I tried to export a word document from an excel macro as PDF, but when I try to run the macro the error "Named argument not found" pops up and highlights "Type:=", I don’t know if I need to add a reference or something, What am I missing?

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdCell As Word.cell

With wdDoc
        saveLocation = "https://orgindustrie-my.sharepoint.com/personal/different_person_org_com/Documents/folder/subfolder"
        .ExportAsFixedFormat Type:=xlTypePDF, _
             Filename:=saveLocation & "/" & "File" & Range("G1").Value & ".pdf"
        .Save
        .Close
End With

I am pretty new to vba, so I don’t know what I’m doing wrong. Many thanks for all the help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You’re conflating the Excel method Workbook.ExportAsFixedFormat and the Word method Document.ExportAsFixedFormat.

For Word:

Parameters

Name Required/Optional Data Type Description
OutputFileName Required String The path and file name of the new PDF or XPS file.
ExportFormat Required WdExportFormat Specifies either PDF or XPS format.

So:

    .ExportAsFixedFormat ExportFormat:=wdExportFormatPDF, _
        OutputFileName:=saveLocation & "/" & "File" & Range("G1").Value & ".pdf"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading