Reputation: 195
I've found a bit of VBA script that works:
Sub ExportToPDF()
With Sheets("Results").Range("B10:J100")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:="C:\Export.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End With
End Sub
I'm still learning VBA, I do not actually need the range to be saved as a separate file, I just want the range selected to be published as a PDF that opens up.
I am not sure how to amend the above code
Upvotes: 1
Views: 1947
Reputation: 195
In order to export to PDF, a file must be saved to a drive. For a spreadsheet that will be used by multiple users, the FileName
in the VBA script must be a generic drive all users have access to.
Upvotes: 0
Reputation: 767
After the
End With
in your code, you can add
CreateObject("Shell.Application").Open ("C:\Users\tjb1\Desktop\Export.pdf")
That code worked for me.
Good luck!
Upvotes: 1