I'd like to trap a Word command; and If a condition is true run
MyMacro, Else run the regular Word macro.

I know that I can trap the build-in macro just using the same name;
but then I won't be able to run the old macro anymore.

How can I achieve this?

thanks, Lauro

Re: Intercepting Word Commands, but using Build-in Macro by Helmut

Helmut
Thu Apr 27 16:08:33 CDT 2006

Hi Lauro,

like this:

Sub FilePageSetup()
Dim oDlg As Dialog
Set oDlg = Dialogs(wdDialogFilePageSetup) ' <<<
If Date = "2006-04-27" Then
MsgBox Date
Else
oDlg.Show
End If
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


Re: Intercepting Word Commands, but using Build-in Macro by Jezebel

Jezebel
Fri Apr 28 03:49:21 CDT 2006

There are no built-in macros. What you trap are built-in commands; but each
has an equivalent as a method, mostly of the application or document object,
as -- as Helmut explains -- as a dialog. From your own macro, call the
actual method you want.




"Lauro" <colasanti@mclink.it> wrote in message
news:fha252l16t20fjo01fm8r5p40j2aetat7d@4ax.com...
> I'd like to trap a Word command; and If a condition is true run
> MyMacro, Else run the regular Word macro.
>
> I know that I can trap the build-in macro just using the same name;
> but then I won't be able to run the old macro anymore.
>
> How can I achieve this?
>
> thanks, Lauro



Re: Intercepting Word Commands, but using Build-in Macro by Lauro

Lauro
Fri Apr 28 09:57:47 CDT 2006

Thanks to both of you. Lauro

Re: Intercepting Word Commands, but using Build-in Macro by Klaus

Klaus
Sat Apr 29 00:41:10 CDT 2006

With many commands, you can just use the same name as the command, but with
"WordBasic." in front (say, WordBasic.Bold).

But with dialogs (such as FilePageSetup) that doesn't work. If you really
want to run the built-in command, and not some corresponding VBA code (...
sometimes there are subtle differences), you should be able to use something
like

Application.EnableCancelKey = wdCancelDisabled
WordBasic.ToolsMacro Name:="FilePageSetup", Run:=1, Show:=2
Application.EnableCancelKey = wdCancelInterrupt

Klaus


"Jezebel" <warcrimes@whitehouse.gov> wrote:
> There are no built-in macros. What you trap are built-in commands; but
> each has an equivalent as a method, mostly of the application or document
> object, as -- as Helmut explains -- as a dialog. From your own macro, call
> the actual method you want.
>
>
>
>
> "Lauro" <colasanti@mclink.it> wrote in message
> news:fha252l16t20fjo01fm8r5p40j2aetat7d@4ax.com...
>> I'd like to trap a Word command; and If a condition is true run
>> MyMacro, Else run the regular Word macro.
>>
>> I know that I can trap the build-in macro just using the same name;
>> but then I won't be able to run the old macro anymore.
>>
>> How can I achieve this?
>>
>> thanks, Lauro
>
>