I don't necessarily see anything wrong with the code but I wonder if
it has anything to do with changing the default printer for Windows
instead of changing the printer just for Word.
Take a look at this article for the code you need to use to change the
printer just for Word:
http://word.mvps.org/FAQs/MacrosVBA/ChangeCurPrinter.htm
I'm also wondering if printer driver is a network printer driver,
rather than a local printer driver, and the reason you encounter the
error is because the network is unavailable (this can happen if you
have the workstation set to AutoDisconnect). If Word queries the
printer driver and it is unavailable then Word can crash. If you
think this is the issue then remove the printer and add it back using
the Add Printer Wizard so a local printer driver will be installed.
btw, the parenthesis around your MsgBox arguments are unnecessary and
really should only be used if you are passing the value of the button
that is clicked to a variable such as:
intResponse=MsgBox("Message prompt", vbYesNo + vbQuestion)
If intResponse=vbYes then
'Code
Actually for your error handler I recommend using something like:
MsgBox Err.Number & " - " & Err.Description
That way if you do encounter an error you don't end up getting a
generic error message. Instead the message may held shed some light on
why the error has occurred.
Consider a generic message such as "winword.exe has encountered an
error" vs. "The network printer is not available". ;-)
--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.
~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP
Word FAQ:
http://mvps.org/word
TechTrax eZine:
http://mousetrax.com/techtrax/
MVP FAQ site:
http://mvps.org/