Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    macro for page setup and printing (Word 2000)

    I have a user who gets a lot of Word documents that are set up for manual print. He would like the documents to automatically print to his printer without him having to do anything but hit "print" on his computer. I wrote a macro to change the page setup to autoselect but when I add the print command to the macro, it wants to print the document to the printer used when recording the macro, not the default printer on that computer. The problem is this user has 2 different offices so I need to figure out how to set the macro to use the default print for the computer he is on at the time. He uses the same normal.dot at each computer. Suggestions or better ideas how to accomplish this? Thanks

  2. #2
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: macro for page setup and printing (Word 2000)

    Hi,

    See if <A target="_blank" HREF="http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=183">Controlling the Printer from Word VBA
    </A> is of any help...

    Cheers
    Regards,
    Rudi

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro for page setup and printing (Word 2000)

    If you still have problems, please post or attach your code.

  4. #4
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro for page setup and printing (Word 2000)

    I looked at the site Rudi recommended but I don't think I know enough about Visual Basic to know what to do. My goal is that this macro will send the job to the default printer, no matter what computer I am on. Is that possible? I've copied the code in the attached document.
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro for page setup and printing (Word 2000)

    This is strange. There is nothing in your macro that selects a printer.
    Word doesn't store info about the printer in a document. When you start Word, it'll use the default system printer until you explicitly select another printer. It will then continue to use that printer until it is changed again or until Word is closed. Next time, it'll start with the default system printer again.
    So I don't know why your documents don't print to the default user. You could try the following code. It'll retrieve the name of the default system printer from the registry and tell Word to use it:
    <code>
    Dim strPrinter As String
    strPrinter = System.PrivateProfileString("", _
    "HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows", _
    "Device")
    strPrinter = Split(strPrinter, ",")(0)
    Application.ActivePrinter = strPrinter
    </code>
    This should be set before printing the document.

  6. #6
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro for page setup and printing (Word 2000)

    Thanks Hans. When I was recording the macro, I just clicked ctrl+p so send it to the printer. Can I just add this code to my existing macro so the print job will go to the default printer? Thanks

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro for page setup and printing (Word 2000)

    You can copy the code from my previous reply and paste it into your macro, above the line

    Application.PrintOut ...

  8. #8
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro for page setup and printing (Word 2000)

    Hans, I think that did trick! Thanks for your help.

  9. #9
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro for page setup and printing (Word 2000)

    Can you check this for me? I got it to work once where I changed the default printer on the computer and running the macro changed it from manual feed to auto select and to the new default printer but now it isn't. I don't know if I messed it up or what I did.

    My other question is about copying this from my normal to someone else's normal. Here are some instructions I found--should this work?
    "In word, go to Tools>Macro>Macros>highlihgt your macro> edit>file > Export file. copy the .bas to the hard drive of the computer you want to copy the macro to and in Word, go to tools> macro>visual Basic Editor>file>import file."

    As always, thanks for your help!
    Attached Files Attached Files

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro for page setup and printing (Word 2000)

    1) I can only check whether the code switches to the default system printer, and it does on my PC.

    2) Yes, this is a good way to copy a macro. If you are all on a network, another way to share the macro would be:
    - Create a new template.
    - Create a module in the template.
    - Copy and paste the code into this module.
    - Save the template in a shared network folder.
    - Let each user who wants to use this, point his/her Startup folder for Word to this network folder (in the File Locations tab of Tools | Options...)
    - Next time Word is started, it will load the template automatically and make the macro available.

Posting Permissions

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