Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help!!! (word2000)

    Hello All,
    Is it possible to trap the event function that is triggered when the buttons are clicked or dropdown lists are selected in the standard tool bar in Word 2000 and above? Basically I want to write my own set of statements when a user clicks on the bold button or makes changes in the style, like changing it from Normal to Heading1. Is this at all possible , if so can anyone let me know as to what I need to do?

    Any help will be appreciated.

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

    Re: Help!!! (word2000)

    > I want to write my own set of statements when a user clicks on the bold button

    This one is easy, just write a Macro called Bold

    For a full list of Macro names for word commands you can download a zip file from Word for Windows commands, and their descriptions, default shortcuts and menu assignments on the MVPS web site

    StuartR

  3. #3
    New Lounger
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help!!! (word2000)

    Thanks stuartR
    It works in the template but, I am building a dll and I cant figure out a way to do that in the Dll. where do I put the function and how do I make it work? Can You help me here??????
    Regards

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

    Re: Help!!! (word2000)

    Sorry, I have no experience of building DLLs to intercept word commands, can anyone else help?

    StuartR

  5. #5
    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: Help!!! (word2000)

    Every CommandBar control (toolbar button or menu item), when clicked, generates an event that can be recognized by its ID. Check out <!post=Post #92036,92036>Post #92036<!/post> for an example. You can determine the ID through a variety of methods. Probably the easiest is to use this macro:
    <pre>Sub ShowMeControls()
    Dim strBar As String, cBarCtrl As CommandBarControl
    strBar = InputBox("Enter name of toolbar")
    For Each cBarCtrl In CommandBars(strBar).Controls
    Debug.Print cBarCtrl.Caption, cBarCtrl.ID
    Next
    End Sub</pre>

    Enter Formatting as the name of the toolbar, then open the Immediate window to see the results. Note that menus are a bit messier, and this macro doesn't handle them. Hope this helps.

  6. #6
    New Lounger
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help!!! (word2000)

    Hi StuartR and Jscher2000,
    Sorry for not acknowledging the reply earlier, wanted to test it out. Thanks for the replies.....jscher what I alternatively did was to create a commandbarbutton variable and assign it to the buttons which I needed to trap. Then used the inbuilt click event for those new commandbuttons to write my code.
    Something like this:

    ***********************************
    ###Declared it

    Dim WithEvents boldButton As CommandBarButton
    Dim WithEvents styleCombo As CommandBarComboBox

    ###Set it the control which I wanted to trap within a module

    Set boldButton = Word.CommandBars("Formatting").Controls(5)
    Set styleCombo = Word.CommandBars("Formatting").Controls(1)

    ####Used the inbuilt events
    Private Sub boldButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    ###My code went here
    End Sub

    Private Sub styleCombo_Change(ByVal Ctrl As Office.CommandBarComboBox)
    ###My code went here
    End Sub

    ************************************************** ********************

    The menu items also dint give a problem because of the inbuilt change event. Thanks you guys for the prompt replies.

    Regards

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

    Re: Help!!! (word2000)

    That's very nice, I can see me using it sometime.

    If you create a Macro called Bold it will trap the button, and Control-B and any other method of activitating the Bold function.
    This method appears only to incercept the button. If that is what you want then this may not be a problem.

    StuartR

Posting Permissions

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