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.
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.
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
Any suggestions? Thanks.