Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Intercepting Word Commands? (Word 2K/XP)

    I have tried the approaches in some previous posts to intercept commands in Word (by means of creating macros with the same name) and found something strange. Some commands are intercepted perfectly but others are not intercepeted. One interesting thing is that the DrawInsertTextBox can be intercepted while DrawInsertOval cannot. I am wonder whether it is some omission of Microsoft. Others that I think should be intercepted but are not include DrawGroup, FillColor, etc.

    I need to intercept most of the Word command in my project. Any hints would appreciated.

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

    Re: Intercepting Word Commands? (Word 2K/XP)

    DrawTextBox (I don't know DrawInsertTextBox) is an internal Word command (the equivalent of Insert | text Box); it can be intercepted. There is no separate Word command for ovals, so there is nothing to intercept. You can download a list of Word for Windows commands, and their descriptions, default shortcuts and menu assignments from the Word MVP site.

  3. #3
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    Hi, Hans. Thanks for you quick reply.

    I have read that command list, but still have something that I cannot understand. For example, the command DrawGroup is in the list but cannot be intercepted by creating a macro with the same name. Are all the commands in the list interceptable or do I need other techniques to do so?

    Regards

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

    Re: Intercepting Word Commands? (Word 2K/XP)

    Frankly, I don't know. The WordCommands list contains some comments about macros not intercepting actions; I have no extra information.

  5. #5
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    Thanks anyway. At least I can intercept some of them based on your previous posts.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    I can interecept DrawGRoup in Word 2003.
    The Sub must be Public and must be avaiable in the project or, maybe, in a global template.

  7. #7
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    Hi Howard,

    I was unable to intercept DrawGroup in Word 2003 (and it doesn't show in the list of commands generated by the ListCommands command). Command command command. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    What were you doing when you invoked the command and intercepted it?

  8. #8
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    I tried in both 2K and XP but failed in both. I do not have a Word 2003 at hand so cannot test. Is it a bug only solved in 2003? But it seems unlikely.

    I put the Sub in the "All active templates and documents". The code is rather simple and I cannot see any error in it.

    Sub DrawGroup()

    MsgBox ("Group")
    WordBasic.DrawGroup

    End Sub

  9. #9
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    In my Word 2K the command DrawGroup showed up when I executed ListCommands but it does not in my Word XP. However, when I created the macro DrawGroup in Word XP, it automatically put the statement WordBasic.DrawGroup in the sub, which acknowledges that it is an internal command in Word (I think). But neither version works to intercept.

    What a strange application! I don't know what they are thinking about when they designed it.

  10. #10
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    Yeah, I remember being elated to find "Style" listed as a command that could be intercepted -- I hoped that meant that I could intercept the application of particular styles. You can even do the Word Commands -> Create on Style, and it gives you:

    <pre>WordBasic.Style
    </pre>


    But that command is useless without an argument, and regardless, once created, I've yet to find anyway to show that it's intercepting anything. Argh.

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    Option Explicit

    Private Sub TestIntercept()
    DrawGroup
    End Sub

    Public Sub DrawGroup()
    Debug.Print "DrawGroup intercepted"
    End Sub

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    "thinking"?
    "designing"?

    Maybe we need to add

    <pre>With Microsoft
    With .Word
    .FixBugs =True
    .LearnHowToDesignSoftware = True
    With SoftwareQualityAssurance
    .LearnHowToDoSQA = True
    End With
    End With
    .AllOfTheAbove = True
    .AndThenSome = True
    End With

    Dim bug as Word.Bug
    For Each bug in Word.Bugs
    bug.fix
    Next bug
    Set bug = Nothing
    </pre>


  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Intercepting Word Commands? (Word 2K/XP)

    I Just rebooted to a system with Word 2002.
    I was able replace DrawGroup.

    In all cases, I am (ab)using English (US) version of Word.

    Perhaps, those having problems have not installed particular Word options?

  14. #14
    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: Intercepting Word Commands? (Word 2K/XP)

    Maybe a better test is whether you can intercept this:

    CommandBars.FindControl(Id:=164).Execute

    (Of course, you should be able to intercept it by setting up a class to watch for CommandBar events... some past examples:

    <table border=1 cellspacing=0 cellpadding=5><td>Word: </td><td>Re: Disabling Email in Word (Office 2000 Word)</td><td>PowerPoint: </td><td>Re: Autosave everytime i quit power point (2000)</td><td>Outlook: </td><td>Re: Outlook COM ADD IN (Office XP VBA6)</td></table>
    I think the question is: is there a simpler way in this case?)

  15. #15
    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: Intercepting Word Commands? (Word 2K/XP)

    You could experiment with intercepting CommandBar events. See <post#=388718>post 388718</post#> (further up in this thread) for some code examples. I think in the past someone described a good way to iterate through the command bars to extract IDs, but that probably would take some energy to find. You can get a sense by using the Locals window and simple code like this (look for .Caption and .Id):

    Sub SniffDrawingCBar()
    Dim cBar As CommandBar
    Set cBar = CommandBars("Drawing")
    Stop ' Drill down through Controls collections in the Locals window
    Set cBar = Nothing
    End Sub

    Hope this helps.

Page 1 of 3 123 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
  •