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
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