OK, I know that I'm bringing up a really old post, but I followed this, as it will help me, and I'm getting an error.
I'm sending all the charts in my spreadsheet to pdf. I know that the macro works, but I have to switch my default printer before I run it each time to make it work.
My old code (before I made this change), reads:
-----------------------------------------------
Sheets(Array("Temps", "North", "South", "Loc1", "Loc2", "Loc3", "Loc4", _
"Loc5", "Loc6")).Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="docuPrinter on Ne02:", printtofile:=True, Collate:=True, _
PrToFileName:=PSnme
Dim myPDFDist As New PdfDistiller
myPDFDist.FileToPDF PSnme, PDFnme, tempShowWindow
Kill PSnme
Kill Lognme
End Sub
-----------------------------------------------
My modified code, following this post, reads:
-----------------------------------------------
Sheets(Array("Temps", "North", "South", "Loc1", "Loc2", "Loc3", "Loc4", _
"Loc5", "Loc6")).Select
originalPrinter = Application.ActivePrinter
Application.ActivePrinter = "docuPrinter on Ne02:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="docuPrinter on Ne02:", printtofile:=True, Collate:=True, _
PrToFileName:=PSnme
Dim myPDFDist As New PdfDistiller
myPDFDist.FileToPDF PSnme, PDFnme, tempShowWindow
Kill PSnme
Kill Lognme
Application.ActivePrinter = originalPrinter
End Sub
-----------------------------------------------
The problem is that now, when I try to run the macro, I get a message,
Run-time Error '1004':
Method 'ActivePrinter' of object '_Application' failed
When I click on debug, it has the following line hi-lited:
Application.ActivePrinter = "docuPrinter on Ne02:"
-----------------------------------------------
Can you help me figure out what's wrong with my code? I'm using Excel 2003.
Thanks!