Printing PDF Macro

conner82

New Member
Joined
Apr 10, 2013
Messages
2
Hi,
I am trying to create a macro which saves my worksheet as a pdf using cute pdf to a file on my c drive with the name being defined by a cell in my worksheet.

I got this to work at my last company so it is frustrating that I cannot get it to work now. The code I used was:

Sub MakePDF()

Filename = "C:\Users\justin\Desktop\New folder\" & ActiveSheet.Range("G1").Value & ".pdf"
Application.ActivePrinter = "CutePDF Writer on CPW2:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", Collate:=True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 4
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Filename = "C:\Users\justin\Desktop\New folder\" & ActiveSheet.Range("G1").Value & ".pdf"
SendKeys Filename & "{ENTER}", False

End Sub

At my last job I remembered that I had to put a time delay in as some of the older computers were slow.

Also when I first used this I was using 2000 & I am not using 2010.

I can get this code to run but it will not enter the file name.

Kind Regards
Justin
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I was begining to think i had asked a silly question as i had no replies! so cheers for the reply Derek.

I'll have to wait until Monday when I am back at work to see it that works.

Has something changed then as it used to work fine when I was running 2003 and cutepdf?
 
Upvote 0
I am unable to answer that question as I have never tried CutePDF with 2003.
Looking at the CutePDF web page (CutePDF :: SDK :: Custom PDF Writer), it seems to indicate in the paragraph "Custom PDF Writer with programmatic access" that it is not possible to specify the filename for use with the "CutePDF Writer".
Other links that may interest you (but they don't say which version of Excel is being used) are:
http://www.mrexcel.com/forum/excel-questions/495433-print-pdf-file.html
http://www.mrexcel.com/forum/excel-...-basic-applications-print-cutepdf-writer.html
Printing to a Cute pdf printer
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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