VBA to save doc as pdf

excel.vba

New Member
Joined
May 26, 2011
Messages
30
Hello,

I am currently working on a project that requires me to save the excel sheet as a word doc. After which the word doc will be saved as a pdf as well. I need all this to run using a vba code. Currently i have been able to code until the saving as a word doc. I am not sure how to continue code the saving of the word doc as a pdf automatically. I have managed to save the excel sheet as a pdf but the formatting gets all off. So instead I just need the saved word doc instead to be converted to pdf.

I am using Excel 2003 so i am using CutePDF as a PdfWriter.

Thanks. Any help would be appreciated.

Below is the code i am using to save the excel sheet as pdf
Code:
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", Collate:=True


newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime


Filename = Path & "\Memo_" & ActiveSheet.Name & "_" & Month & ".pdf"



SendKeys Filename & "{ENTER}", True
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top