Results 1 to 13 of 13
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Printer Changes (VBA-Word2000-SP3 - WinXP)

    Hello all!
    Suddenly one of my macros stopped working and I'm at a complete loss for a cause!

    The code is pretty simple [and very similar to posts I've seen here which function similarly...]

    Dim Default As String

    'capture default printer into variable
    Default = ActivePrinter

    'open print dialog box
    Set myDialog = Dialogs(wdDialogFilePrint)
    'set printer to color
    ActivePrinter = "printerserverCOLOR" 'which is what shows up in the dialog if you manually select
    myDialog.Update
    myDialog.Show

    'Return printer to the default setting
    ActivePrinter = Default

    Changing the active printer to the color printer is the line that just hangs. An hour glass appears and that's the end of the story. I have to end task on Word. This macro has worked for seven years!! Until yesterday.
    Absolutely nothing about the printer server has changed and the macro still works for SOME people. Of the two folks I'm working with [where macro isn't working], one has Office SP2, the other has Office SP3; both are up to date on Windows criticals. Strangely enough, if the two users use the File > Print method and manually change to print to the color printer - everything's fine.

    Argh! I need a day off! Can anyone help?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    To confirm the printer name or path that Word expects to see, use the Print dialog to change to the desired printer, and then, in the VBE's Immediate window, query the ActivePrinter:

    <code>?application.ActivePrinter</code>

    Mine usually end with some kind of port number (e.g., "on NE06:") which might be necessarily to resolve an ambiguity (for example, if you have PCL and PostScript drivers pointed to the same device).

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Bummer! I added the port number as you suggested - but the line still hangs. What's facinating is that the active printer is actually changing to the color printer. So it looks like the line is executing. I just don't get the dialog box.

    Thanks for your reply, though! I appreciate your time.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Try a short Sleep in case Word needs additional time to read the configuration from the network.

    'Windows API declaration for top of module:
    <code>Private Declare Sub Sleep Lib "kernel32" (ByVal nMilliseconds As Long)</code>

    'Sample call
    <code>Sleep 500 'wait 1/2 sec before proceeding</code>

  5. #5
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Drats! Still hanging on the line setting active printer. I put the sleep before & after and even tried to increase the sleep.
    But the sleep does not seem to make a difference.
    I just don't understand!
    Thanks again for your suggestions - they are very appreciated.

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Just to check there aren't any leading or trailing spaces or other similar stuff in your printer name. Could you check the output of the following command from your Immedaite Window in VBA.

    Debug.Print """" & Application.ActivePrinter & """"

    Then make absolutely sure that you include the exact string that this returns in your macro.

    StuartR

  7. #7
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Done! Word for word & space for space - there's a perfect match.
    Still - I get the hang.
    Thanks for the suggestion!

    I wish I could put my finger on what changed for two people that didn't change for others... I'm not able to put my finger on anything!

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Just a shot in the dark!

    Do your two problem users have "printerserver" as a mapped drive?
    Do the non-problem users?
    Have you tried changing the command to "ActivePrinter = "COLOR" and letting the system find the printer.

    You may wish to try the following simplified code:
    <div style="width: 100%; background-color: #FFFFFF;"><code><font color=black><font color=blue>Option</font color=blue> <font color=blue>Explicit</font color=blue>

    <font color=blue>Public</font color=blue> <font color=blue>Sub</font color=blue> ptr()
    <font color=blue>Dim</font color=blue> Default <font color=blue>As</font color=blue> <font color=blue>String</font color=blue>

    <font color=448800>'capture default printer into variable</font color=448800>
    Default = ActivePrinter

    <font color=448800>'set printer to color</font color=448800>
    ActivePrinter = "printerserverCOLOR" <font color=448800>'which is what _
    shows up in the dialog if you manually select</font color=448800>

    <font color=448800>'open print dialog box</font color=448800>
    Dialogs(wdDialogFilePrint).Show

    <font color=448800>'Return printer to the default setting</font color=448800>
    ActivePrinter = Default
    <font color=blue>End</font color=blue> <font color=blue>Sub</font color=blue>

    </font color=black></code></div hiblock>
    Regards
    Don

  9. #9
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Hello!
    To answer your questions, "printerserver" is not mapped for any of us - the problem users or the non-problem users.
    I tried your suggestion of just putting "Color" and letting the system find the printer, but got a runtime error. Hey, at least a runtime error beats the application lockup! )

    I also tried your code - but still get the hang on that Active printer line: ActivePrinter = "printerserverCOLOR"
    It looks like it WANTS to work because it does change my default printer to the color printer... but the code just stops there...

    Have a good weekend, everyone. And again - thanks for all suggestions.

  10. #10
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Have you tried re-installing the printer driver for printerserverCOLOR on one of the problem machines?
    Regards
    Don

  11. #11
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Done!
    Completely removed driver & printer ... then re-installed.
    Still the same.

  12. #12
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    Does your network allow users to log on using someone else's machine, but their own username? If so have you tried one of the problem users on a good machine? and vice versa?
    Regards
    Don

  13. #13
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printer Changes (VBA-Word2000-SP3 - WinXP)

    I just tried to run this code and apparently lost a DLL recently. Any recommendations?
    <div style="width: 100%; background-color: #FFFFFF;"><code><font color=black><font color=blue>Private</font color=blue> <font color=blue>Declare</font color=blue> <font color=blue>Sub</font color=blue> sleep <font color=blue>Lib</font color=blue> "kernel32" (<font color=blue>ByVal</font color=blue> nMilliseconds <font color=blue>As</font color=blue> <font color=blue>Long</font color=blue>)

    <font color=blue>Sub</font color=blue> mt()
    sleep 10000 <font color=448800>'wait 1/2 sec before proceeding</font color=448800>
    MsgBox "Time's up!"
    <font color=blue>End</font color=blue> <font color=blue>Sub</font color=blue>


    </font color=black></code></div hiblock>

    I just figured it out. In the declaration " Sleep " is case sensitive.
    Attached Images Attached Images
    Regards
    Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •