PDA

View Full Version : Word 2003 Macro Error 1121


Phil_B
October 18th, 2006, 03:57 PM
Hi, I am getting a rather annoying problem with a Word macro that I set up to enable a user to click a button to send to a different default printer that I was hoping someone could help with.

In short, they need several versions of the same driver with different defaults for A4 mono, A4 colour, A3 mono, A3 colour.

So I set up the four drivers with their defaults on the print server (2003), then setup the following macros (or atleast just one for testing right now):

Sub SwitchPrinter()
Dim strActivePrinter As String
' Get active printer.
strActivePrinter = Application.ActivePrinter
' Change to the Colour Default printer driver.
Application.ActivePrinter = "A4 Colour"
' Print the active document to Colour Driver.
ActiveDocument.PrintOut
' Change back to the default printer.
Application.ActivePrinter = strActivePrinter
End Sub

This works fine with locally installed (local TCP/IP port) printers, but when I try and user the print server (with identical naming, and local dribers removed) I get the macro error 1121, highlighting the
*Application.ActivePrinter = "A4 Colour"* line

Yet this is definately named correctly!

Am I to conclude that Word macros will not support printer switching to printe server hosted devices?! Sounds like nonsense to me, but grateful if anyone has had a similar experience.

Unfortunately local IP printing is not an option, as although there are only 5 users, printing activity is logged for charging purposes at the print server, and of course this would circumnavigate this.

Thanks for any help :happy:

Phil_B
November 21st, 2006, 05:31 PM
Any thoughts on this anyone?

It's still a problem that I haven't found any resolution to.

If it can't be done could someone put me out of my misery?

smurfy
November 21st, 2006, 10:46 PM
I have no idea personally but I'm guessing it has to do with the naming by the print server - sharename may be different to printername?

http://msdn2.microsoft.com/en-us/library/aa212494(office.11).aspx

This article looks promising:
http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=183
Change a workstation to use one of the printers you want to use then run the msgbox code to display the object properties as VBa sees it. Then you'll be able to assign the name as VBa expects to see it in your code.

oracle128
November 22nd, 2006, 09:52 AM
Have you tried using the UNC path to the printer, ie "\\PRINTSERVER\A4 Color"?

Phil_B
November 22nd, 2006, 04:52 PM
Thnaks guys. I am confident names match, as per initital post, but I will try both suggestions and post feedback.

Thanks again for your input