Macro to open built-in dialog in Word 2003

A

Alan Stancliff

This question deals with Word 2003 on Windows XP.

I know, in general, how to add a command or macro to the toolbar by
clicking on Tools>Customize, clicking on the Commands tab, scrolling
down the Categories list on the left side, highlighting the appropriate
category, and then dragging the appropriate item to the menu bar. But
not everything can be got to that way.

For example, I would like to have a menu item or button that enables one
to go immediately to the dialog box that opens when one clicks
Tools>Customize>Keyboard with Macros highlighted in the left-hand side.
The keystrokes, which are not recordable to bring up this dialog, in the
macro recorder, would b. the following: <alt><T>, <alt><C>, <alt><K>,
<alt>C>, <M>,<M>,<Right>.

How would I write a macro that does this? I have an AutoHotKey script
that does this, but I wanted to have a macro that does this.

Regards,

Alan Stancliff
 
D

Doug Robbins - Word MVP

Using the SendKeys command might do it.

SendKeys "%T%C%K%C{M 2}{Right}"

I can't test it as I am using 2007 in which the Tools>Customize dialog is
not available. That is not quite true, it inserted the local time in AM/PM
format followed by MM

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

Alan Stancliff

Doug said:
Using the SendKeys command might do it.

SendKeys "%T%C%K%C{M 2}{Right}"

I can't test it as I am using 2007 in which the Tools>Customize dialog is
not available. That is not quite true, it inserted the local time in AM/PM
format followed by MM
Thanks for the idea. I did not know that VBA had SendKeys. I did try
your example, but unfortunately it did nothing at all. I tried setting
wait to true and a few other things.

Here's my latest go:

Sub eraseme()
'
'
Dialogs(wdDialogToolsCustomizeKeyboard).Display
SendKeys "m", True
SendKeys "m", True
SendKeys "{right}", True
End Sub

This got me as far as the keystrokes:
<alt><T>, <alt><C>, <alt><K>
which brings up the customize keyboard dialog. What it does not do is
send the <m>, <m>,<right>, which would move the selection bar in the
categories list on the upper left and shift focus to the Macros list on
the upper right. That's where I want to end up. Any ideas anyone?

Regards,

Alan
 
G

Graham Mayor

Try

SendKeys "%T%C%K%C{M 2}"
Dialogs(wdDialogToolsCustomize).Show

or simply

SendKeys "{M}"
Dialogs(wdDialogToolsCustomizeKeyboard).Show

instead!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

Alan Stancliff

Thanks Graham,

Those worked wonderfully well, especially the second:

SendKeys "{M}"
Dialogs(wdDialogToolsCustomizeKeyboard).Show

Once again you guys have been wonderfully helpful.

Regards,

Alan Stancliff
 
A

Alan Stancliff

Graham said:
You know, I have to ask. Why does doing the SendKeys before opening the
dialog work and not visa versa. Somehow, that seems counterintuitive to me.

I'm just trying to understand the logic behind all this.

Regards,

Alan
 
A

Alan Stancliff

Graham said:
You know, I have to ask. Why does doing the SendKeys before opening the
dialog work and not visa versa. Somehow, that seems counterintuitive to me.

I'm just trying to understand the logic behind all this.

Regards,

Alan
 
A

Alan Stancliff

Graham said:
You know, I have to ask. Why does doing the SendKeys before opening the
dialog work and not visa versa. Somehow, that seems counterintuitive to me.

I'm just trying to understand the logic behind all this.

Regards,

Alan
 
G

Graham Mayor

You are welcome :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

Alan Stancliff

My apologies for the double-posting. I was having a bit of a problem
with my software.

Regards,

Alan Stancliff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top