0
votes

I try to save an excel sheet using the following code:

Sub save_as_PDF()

Dim strPath As String, strName As String, strSaveName As String

strPath = "C:\Users\xxx\Documents" strName = "Test.pdf" strSaveName =
strPath & strName

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF,
Filename:=strSaveName, Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True

End Sub

On my old pc - having Excel 2010 and the free Adobe Acrobat Reader, the pdf is created.

However, on my new pc having Excel 2016 and also the free Adobe Acrobat Reader, the pdf is not created. The following error is thrown: Error 430 - Runtime Error Class Does Not Support Automation Or Does Not Support Expected Interface.

I tried to install the test version of Adobe 11 Pro, which did not help. Also, I'm able to create a PDF via the manual print command.

1

1 Answers

0
votes

I believe your only problem is syntax error with:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF,

The command ends there but it needs the arguments below it.

Change it to:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _

that space and underscore tell VBA to continue on the next line instead of ending the command so it will pickup the arguments it needs.