Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Turn Off Print Settings (Word 2003)

    Hi,

    Im curious to know if its possible to turn off Word's print default settings, that is, to stop the user from going to File, Print (greying out the print option), or greying out the printer icon on the tool bar, to print a document?

    I ideally need to force the user to use a custom button on the toolbar to print via a macro.

    Cheers.
    Lee

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

    Re: Turn Off Print Settings (Word 2003)

    You could run the DisablePrint macro:

    Sub DisablePrint()
    ToggleItems False
    End Sub

    Sub EnablePrint()
    ToggleItems True
    End Sub

    Sub ToggleItems(f As Boolean)
    On Error Resume Next
    ' File menu items
    Commandbars("File").Controls("Print...").Enabled = f
    Commandbars("File").Controls("Print").Enabled = f
    ' Toolbar items
    CommandBars.FindControl(ID:=4).Enabled = f
    CommandBars.FindControl(ID:=2521).Enabled = f
    End Sub

    To enable the menu items and toolbar buttons again, run EnablePrint.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    Great, thanks Hans.

    The only thing is, Im not sure how to amend Word so the macro runs upon Word being opened. Do you have any ideas maybe?

    Cheers.
    Lee

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

    Re: Turn Off Print Settings (Word 2003)

    Is this for yourself, or for use by others?

  5. #5
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    It will be for a handful of individuals, all local machines.

    Cheers.
    Lee

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

    Re: Turn Off Print Settings (Word 2003)

    Create a template (.dot).
    Place the code in a module in this template, and add a macro named AutoExec:

    Sub AutoExec()
    DisablePrint
    End Sub

    Users should place this template in their startup folder for Word, this will make it load automatically when Word is started.
    The default location of the startup folder is Cocuments and Settings<username>Application DataMicrosoftWordStartup. This is inside a hidden folder, so you must display hidden files and folders to see it.

  7. #7
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    Thanks very much Hans, thats just what I need.

    Much appreciated.

    Cheers.
    Lee

  8. #8
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    Hi Hans,

    Sorry to bother you on this again, but is it possible to envoke the macro to turn off the default print options when a particular document is produced in Word?

    The background to this is basically that one document inparticular has to be printed by a duplex printer. My theory being that when word is opened it runs macro "PrinterLee", as below, checks the document for the bookmark and in theory if found it will turn off the default Word print options. It will then call a macro to switch the default printer to duplex and then after printing return to the original default printer.

    Ive being trying to label the document with a bookmark as detailed with the macro below;

    Sub PrinterLee()
    With ActiveDocument

    If .Bookmarks.Exists("bm2lenders") = True Then
    Call DisablePrint
    End If

    End With

    End Sub


    Sub DisablePrint()
    ToggleItems False
    End Sub

    Sub EnablePrint()
    ToggleItems True
    End Sub

    Sub ToggleItems(f As Boolean)
    On Error Resume Next
    ' File menu items
    CommandBars("File").Controls("Print...").Enabled = f
    CommandBars("File").Controls("Print").Enabled = f
    ' Toolbar items
    CommandBars.FindControl(ID:=4).Enabled = f
    CommandBars.FindControl(ID:=2521).Enabled = f
    End Sub

    I then need help with the code to switch from the default printer to duplex and then back again?

    Any help you can give is much appreciated.

    Cheers.
    Lee

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

    Re: Turn Off Print Settings (Word 2003)

    Does this help?
    <pre>Sub SwapPrinter()
    Dim defPtr As String

    defPtr = ActivePrinter
    ActivePrinter = "Your Duplex Printer Name goes here"
    '
    '
    '
    '
    ActivePrinter = defPtr

    End Sub
    </pre>

    Regards
    Don

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

    Re: Turn Off Print Settings (Word 2003)

    The easiest way to switch between simplex and duplex printing is to create two printers in the Printers and Fax Devices control panel, both printing to the same physical printer, but one set to print single-sided and the other set to print double-sided. You then only have to set Application.ActivePrinter to the appropriate printer name.

    Otherwise, switching requires rather complicated code using Windows API functions. See Controlling the Printer from Word VBA or HOWTO: Set Duplex Printing for Word Automation.

    If you need the code for a single document only, you shouldn't put the code in a general template, but in that document. You can use application-level events to monitor switching between documents, See the attached example. It only handles turning the printer icons on and off, not duplex printing.
    Attached Files Attached Files

  11. #11
    Lounger
    Join Date
    Jul 2003
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    Hans
    How does one find the ID of a button? Your code attached in the above post does not work for me. The reason being I am using a customized toolbar instead of the "Standard" toolbar.
    Is this simple to figure out?

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

    Re: Turn Off Print Settings (Word 2003)

    For a specific item, you can type something like the following in the Immediate window:

    ? CommandBars("Standard").Controls("Open...").ID

    or

    ? CommandBars("Standard").Controls(2).ID

    See <post:=200,111>post 200,111</post:> and <post:=204,976>post 204,976</post:> by JScher2000 for two different macros that list the IDs of toolbar buttons and menu items.

    However, for custom buttons, the ID is always equal to 1. For those, you can use code like

    CommandBars("Custom Toolbar").Controls("Custom Print").Enabled = False

  13. #13
    Lounger
    Join Date
    Jul 2003
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    I am coming up with the same ID number (#2521) for the Print button on my toolbar titled "MyStandard"

    So I tried to edit the code to CommandBars("MyStandard").Controls("Print").Enable d = False. Now the print button is disabled in all documents.
    I think this is beyond my expertise. Thanks anyway.

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

    Re: Turn Off Print Settings (Word 2003)

    The code in the ThisDocument module in the document I attached higher up in this thread should toggle the Print items on and off as the user switches between documents:

    Private Sub app_DocumentChange()
    ToggleItems Not (ActiveDocument = ThisDocument)
    End Sub

    The macro in the module named Module1 is not enough, the code in ThisDocument is essential for this.

  15. #15
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Turn Off Print Settings (Word 2003)

    Great, thanks Hans.

    Ive decided to take the easy option and just create two printers from one, as suggested.

    Cheers.
    Lee

Page 1 of 2 12 LastLast

Posting Permissions

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