Print to PDF issues

mostlymittens

New Member
Joined
Dec 11, 2013
Messages
1
Hi all,

I'm having issues with printing to PDF since half of my team were upgraded to Windows 7. The code below used to work on XP Pro with Office 2007 or Office 2010 but since the upgrade to Windows 7 with Office 2010, it no longer works.

Code:
Sub saveaspdf_click() 'prints to pdf


'tells excel that the filename is equal to the range pdf
FileName = [pdf]


'send the current selected sheets to the PDF printer (on port CPW2)
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDF Printer on CPW2:", Collate:=True


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


'automatically enter the correct filename press the enter key
SendKeys FileName & "{ENTER}", False

End Sub
I've read that this could be due to the SendKeys function not working in Windows 7. Are there any alternatives? I've tried using a macro to Save As PDF rather than print, the result was that the PDF wouldn't even open. I can't use the Adobe Distiller workaround either.

Any suggestions? Thanks.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Check you have adobe reader installed, most likely you had this before and since your upgrade you do not have it.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

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