Reputation: 11
I use VBA in EXCEL to fill a word document with bookmarks. At the end I would like to create and save a pdf of this word document.
I used this line:
.ExportAsFixedFormat2 ThisWorkbook.Path & "\" & sFileName & ".pdf", 17
It works for me, but for a friend she receives Runtime error 438. I am using MS office 365, she uses MS office 2019. Do you know how to make this line working for her also?
Looking forward to your help! Thanks in advance.
Upvotes: 1
Views: 450
Reputation: 119
Alternatively to maintain compatibility with different versions you can try the following...
wordVersion = Application.Version
If wordVersion > 15 Then
ActiveDocument.ExportAsFixedFormat2 _
'followed by parameters
else
ActiveDocument.ExportAsFixedFormat _
'followed by parameters
end if
Upvotes: 0
Reputation: 421
Document.ExportAsFixedFormat2
is not supported for older versions. However, Document.ExportAsFixedFormat
, is.
Thus, removing the ‘2’ should fix the issue:
.ExportAsFixedFormat ThisWorkbook.Path & "\" & sFileName & ".pdf", 17
Upvotes: 1