Can no longer set ActivePrinter

P

Pete

The following VBA macro, which I have used since 1999
without problems, suddenly no longer works. There have
been no changes to my system, network, or printers that
would change its operation. The macro saves the
identification of the currently specified printer, changes
the active printer, prints the document to that printer,
and then restores the original printer.

Sub Print_color()
' Macro recorded 11/9/99 by Pete
'
PrinterNow = ActivePrinter
ActivePrinter = "HP Color LaserJet 4500"
Application.PrintOut FileName:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True,
PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0,
PrintZoomPaperHeight:=0
ActivePrinter = PrinterNow
End Sub

The macro hangs on the "ActivePrinter =" statement on this
and some similar macros I use. I suspect recent Microsoft
security upgrades may block changing the ActivePrinter.
The macro is quite consistent with Knowledge Base Article
162239.

Has anyone encountered similar problems and come up with a
fix?
 
G

Graham Mayor

You could simplify it a bit, but as far as I can see there is no reason why
it should not work - provided of course that the printer entry in the
printer list in control panel exactly matches that in the Active Printer
statement. This technique is what I use myself for printing to different
printers. It still works here with *my* printers and my machine is up to
date with security fixes, so that's does not appear to be the answer.

Sub Print_Color()
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
ActivePrinter = "HP Color LaserJet 4500"
Application.PrintOut FileName:=""
ActivePrinter = sCurrentPrinter
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
G

Guest

Thanks for your help. I guess there is something subtle
going on here that I will have to dig into!
 
G

graphicmd

I am having the exact same problem. I have 75 users down right now and
can't figure out why.

when the code hits this line Application.ActivePrinter = "any printer
just setts with an hourglass until you go into your task manager to en
the program.

If you figure out what is causing this can you please let me know?

Thank
 
G

graphicmd

Pete

Run Ad-Aware, Spybot or antoher Spyware utility. I did that and it
seemed to fix whatever was causing the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top