Results 1 to 8 of 8
  1. #1
    Lounger
    Join Date
    Dec 2000
    Location
    Giessen, Noord-Brabant, Netherlands
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    overriding internal commands (Word 2003/2007)

    I want to override some internal Word commands, but only under certain conditions; otherwise I need the original internal command to run from my VBA procedure. But how? For example,

    Sub IncreaseIndent()
    If Selection.Style = ActiveDocument.Styles("LB") Then
    ListBullet2
    Else
    'run the original internal "IncreaseIndent" here - but how???
    End If
    End Sub

    Thank you so much for any help!
    Robin

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

    Re: overriding internal commands (Word 2003/2007)

    Does

    Selection.Paragraphs.Indent

    do what you want?

  3. #3
    Lounger
    Join Date
    Dec 2000
    Location
    Giessen, Noord-Brabant, Netherlands
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: overriding internal commands (Word 2003/2007)

    Hans,

    thanks, I had in fact already tried that in the procedure that overides the internal "Indent" command; maybe it'll do the job for "IncreaseIndent" too, I'll check it out, and thank you very much. I got the name "IncreaseIndent" and the others listed below by, from the UI, pressing Ctrl+Alt+[NumPad+] and then clicking the Increase Indent button. The name doesn't seem to appear in the object model but that's what Word says the internal command is called. What I'm actually looking for is a generic way of passing control back to Word, so running the command in the application layer, if my procedure (with the same name as the internal command) finds that to be necessary.

    In the code I'm working on I have to override Indent, UnIndent, IncreaseIndent, DecreaseIndent, HangingIndent and UnHang. But all of these only need to change the default behaviour if a certain style is in effect, otherwise I want to pass control back to Word. Any further thoughts? Thanks again,

    Robin

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

    Re: overriding internal commands (Word 2003/2007)

    There is no universal way to find the VBA equivalent of a built-in command. Sometimes it's very easy to find in the VBA help or in the Object Browser (F2), and sometimes you can find it by recording a macro, but unfortunately this doesn't always work.

  5. #5
    Lounger
    Join Date
    Dec 2000
    Location
    Giessen, Noord-Brabant, Netherlands
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: overriding internal commands (Word 2003/2007)

    Ok Hans, thanks very much for your help. Maybe recording a few macros might sort things out for me. All the same, I seem to remember, long ago, that I was able to do something like:

    Sub FilePrint()
    If ItsFriday Then
    MsgBox "No printing on Friday!"
    Else
    Application.Commands("FilePrint") 'or something like this
    End Sub

    ...but I guess I must be mistaken.

    Robin

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

    Re: overriding internal commands (Word 2003/2007)

    You can use

    Application.Run "FilePrint"

    to invoke the FilePrint command but that won't help if you have hijacked it by creating a macro named FilePrint, for Application.Run would call that macro, causing an infinite loop.

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

    Re: overriding internal commands (Word 2003/2007)

    I think that you will find the following construct will not cause an endless loop<div style="width: 100%; background-color: #FFFFFF;"><code><font color=black><font color=blue>Sub</font color=blue> FilePrint()
    <font color=blue>If</font color=blue> Day(Now) = 7 <font color=blue>Then</font color=blue>
    MsgBox "Not printing today"
    <font color=blue>Else</font color=blue>
    Application.PrintOut
    <font color=blue>End</font color=blue> <font color=blue>If</font color=blue>
    End <font color=blue>Sub</font color=blue>
    </font color=black></code></div hiblock>
    Regards
    Don

  8. #8
    Lounger
    Join Date
    Dec 2000
    Location
    Giessen, Noord-Brabant, Netherlands
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: overriding internal commands (Word 2003/2007)

    Don, you and Hans are of course quite right; there really doesn't seem to be a way to do what I was trying. In the end the problem is fixed; I was able to use Selection.Paragraphs.Indent for both Indent and IncreaseIndent, and Selection.Paragraphs.Outdent for the other direction. The Hang and Unhang turned out to be Selection.ParagraphFormat.TabHangingIndent 1, and Selection.ParagraphFormat.TabHangingIndent -1 respectively. Now I can sleep easy! Thanks again guys. RF

Posting Permissions

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