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.
>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"