I use the below marco to create the myPDF.pdf. I get this message when trying to open it. The error said: "Acrobat coult not open 'myPDF.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). To create an Adobe PDF document, go to the source application. Then print the document to Adobe PDF". It works when I do manually from the Excel workbook. Would you point out what I did wrong here in my macro code. Thanks.
___________________________
Thanks, Swi for your quick response. Yes, I did. It required to have the pdfcreator installed from sourceforge.net. I was hoping that I can do it without the pdfcreator. Otherwise, it will require other my users to install it as well before they can use the macros.
Have you tried this ?
MySheet.Range("MyRange").PrintOut copies:=1, preview:=False, ActivePrinter:="Adobe PDF", PrintToFile:=[!]True[/!], Collate:=True, PrToFileName:=PDFFileName
I have 5 different ranges names in the spread sheet and they all have different setting for printing. My goal is trying to create a single pdf file containing all 5 print pages. So far I'm having problem with just one page. Hope you can help.
I'm back. I changed MySheet to Sheets("Fact") then it worked. I though I did not have to define MySheet. I still get the error stated from above: "Acrobat coult not open.."
-----------
Sub Macro5()
'
Dim PDFFileName As String
'
PDFFileName = "E:\myPDF.pdf"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.