Specifically I've built a user form that will allow the user to select a host of reports (or excel tabs with defined print areas) to be printed either in hard copy via the default printer or to print to PDF and save in the respective monthly folder.
There are 2 check boxs one for hard copyand one to print to PDF (a PDF Creator printer in a hosted/Citrix cloud environment). I can't seem to correctly select the PDF printer?
I'm a self taught VBA accontant, not a programmer so please try keep it simple the code I'm using is as follows
Sub PrintToPDF(strSheetToPrint)
Dim strFolder As String
Dim strPathToSaveTo As String
Dim strCurrentPrinter As String
Dim svInputPS
strFolder = Range("TB_FOLDER").Offset(0, (periodx)).Value 'lookup for current month folder name
strPathToSaveTo = "S:\Finance\FY2014\CONSOLIDATED\" & strFolder & "" 'specific path to select in dialogue box
strCurrentPrinter = Application.ActivePrinter ' save the currently active printer
svInputPS = strFolder & "-" & strSheetToPrint & ".pdf" ' defines name of file to be saved
For i = 0 To 15
curNePrint = Format(i, "00")
On Error Resume Next
Application.ActivePrinter = "\\tc1-ps-ETC1\ETC_PDF Creator on wave-pdf1:" & curNePrint & ":"
Next i
Worksheets(strSheetToPrint).PrintOut PrToFileName:=svInputPS, PrintToFile:=True
ActiveSheet.PrintOut ' print the sheet1
Worksheets(strSheetToPrint).PrintOut
Application.ActivePrinter = strCurrentPrinter ' change back to the original printer
End Sub
Most of my code I find on forums like this and copy and tinker with to get it to do what I need. I keep getting an error on selecting the PDF printer...??
Any ideas?
Thanks
There are 2 check boxs one for hard copyand one to print to PDF (a PDF Creator printer in a hosted/Citrix cloud environment). I can't seem to correctly select the PDF printer?
I'm a self taught VBA accontant, not a programmer so please try keep it simple the code I'm using is as follows
Sub PrintToPDF(strSheetToPrint)
Dim strFolder As String
Dim strPathToSaveTo As String
Dim strCurrentPrinter As String
Dim svInputPS
strFolder = Range("TB_FOLDER").Offset(0, (periodx)).Value 'lookup for current month folder name
strPathToSaveTo = "S:\Finance\FY2014\CONSOLIDATED\" & strFolder & "" 'specific path to select in dialogue box
strCurrentPrinter = Application.ActivePrinter ' save the currently active printer
svInputPS = strFolder & "-" & strSheetToPrint & ".pdf" ' defines name of file to be saved
For i = 0 To 15
curNePrint = Format(i, "00")
On Error Resume Next
Application.ActivePrinter = "\\tc1-ps-ETC1\ETC_PDF Creator on wave-pdf1:" & curNePrint & ":"
Next i
Worksheets(strSheetToPrint).PrintOut PrToFileName:=svInputPS, PrintToFile:=True
ActiveSheet.PrintOut ' print the sheet1
Worksheets(strSheetToPrint).PrintOut
Application.ActivePrinter = strCurrentPrinter ' change back to the original printer
End Sub
Most of my code I find on forums like this and copy and tinker with to get it to do what I need. I keep getting an error on selecting the PDF printer...??
Any ideas?
Thanks