Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Location
    Basel, Basel Stadt, Switzerland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    Hi,

    I've just read through this article because I have a similar problem.

    In my event class I took the event DocumentBeforePrint and entered the following code:
    '-------------------------------
    Set dlg = Application.Dialogs(wdDialogFilePrint)
    dlg.Display

    ' Set my printer trays here

    dlg.Execute
    Cancel = True
    '-------------------------------

    The selection of the printer trays works fine, because I read the names of the trays from the driver via API to set them afterwards.
    My problem is the following: If a user pressed the toolbar button "Print" instead of the menu "File / Print", I don't want to show the Print dialog because is doesn't appear usually. For this reason I should know who is the caller of the event. I even searched the toolbar and menu objects to find a property showing which of these two has been pressed without results.
    Do I have to go via API for this, too?

    Thanks for help,
    Marcel

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

    Re: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    I wish that Word had Excel's Application.Caller property, this would solve so many similar problems.

    One way to solve your particular problem is to create a Macro called FilePrintDefault, this will get called instead of the built in Word command whenever the Print button is pressed.

    StuartR

  3. #3
    New Lounger
    Join Date
    Apr 2003
    Location
    Basel, Basel Stadt, Switzerland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    Hi Stuart,

    This seems to be the perfect solution for my problem. I thought this macro has to be inserted into the normal.dot template, but it works on my particular template, too. Since I keep most of my code in an AddIn I don't want to touch normal.dot.

    Now, I will work everything out and see if it's the solution.
    Thank you for your help, <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

    Marcel

    ----> It works perfectly... Thanks

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    This is a bit interesting. Could you answer this for me:

    Word has two methods for printing FilePrint and FilePrintDefault which correspond to
    File | Print... (the menu and Ctrl-P) and Print (the toolbarbutton). Are you indicating
    that the DocumentBeforePrint event fires only when File | Print... is invoked?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    hi Marcel,

    explore the actioncontrol property of the commandbars collection.

    greetings,

  6. #6
    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: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    Couldn't get ActionControl to work for built-in controls, though I tried very hard. See <post#=240839>post 240839</post#> (tested with Word 2000).

  7. #7
    New Lounger
    Join Date
    Apr 2003
    Location
    Basel, Basel Stadt, Switzerland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    Dear Kevin,

    The DocumentBeforePrint-Event fires before every print, no matter if you press the button, use the shortcut or the menu.
    But I wanted to make my application having the same behaviour as Word, i.e. the print dialog had to appear when the print was started from the menu. I just couldn't say where the event was coming from, when I was just using the DocumentBeforePrint-Event.

    Now with Stuart's solution, I am able to differentiate these two event-caller and ether display the dialog or not.

    (This is kind of different to explain.. [img]/forums/images/smilies/ohmy.gif[/img])

    Cheers,
    Marcel

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Caller of a DocumentBeforePrint event (Word 2000 SR-1)

    I understand completely. I just thought you found some trick I didn't
    know about. I've struggled with this same problem related to the
    DocumentBeforeSave event.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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