Making changes to Word's macros dialog - arguments of dialog box

User avatar
Charles Kenyon
4StarLounger
Posts: 596
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Making changes to Word's macros dialog - arguments of dialog box

Post by Charles Kenyon »

In this thread on the Answers forum someone asked about changing the default "look in" parameter for Word's macros dialog. https://answers.microsoft.com/en-us/mso ... 9fb8441238
Although the OP marked my response as an answer, I am looking at it as a challenge.

I was looking at possibly using the Arguments for the dialog box but do not know that it takes arguments. Does anyone know of a way to access the arguments of that dialog box or what they are? In specific, the "look for macros in" window.

I tried SendKeys without success.

Here is my unsuccessful SendKeys code.

Code: Select all

Sub MacroListNormal()
    ' Charles Kenyon
    Application.Dialogs(wdDialogToolsMacro).Show
    SendKeys "{TAB}"
    SendKeys "{TAB}"
    SendKeys "{TAB}"
    SendKeys "{TAB}"
    SendKeys "{TAB}"
    SendKeys "{TAB}"
    SendKeys "{TAB}"
    SendKeys "Normal.dotm"
End Sub
The dialog box does not retain the focus and I get seven tabs entered in the document together with "Normal.dotm."

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Making changes to Word's macros dialog - arguments of dialog box

Post by HansV »

This works for me:

Code: Select all

Sub MacroListNormal()
    ' Charles Kenyon
    SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}Normal.dotm~", True
    Application.Dialogs(wdDialogToolsMacro).Show
End Sub
or, slightly shorter:

Code: Select all

Sub MacroListNormal()
    ' Charles Kenyon
    SendKeys "%aNormal.dotm~", True
    Application.Dialogs(wdDialogToolsMacro).Show
End Sub
%a means Alt+A, this activates the 'Macros in' box, and ~ sends a Return/Enter.
Best wishes,
Hans

User avatar
Charles Kenyon
4StarLounger
Posts: 596
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Making changes to Word's macros dialog - arguments of dialog box

Post by Charles Kenyon »

The following sort of works but can't be assigned to Alt+F8

Code: Select all

Sub MacroListNormal()
    ' Charles Kenyon not working - see
'    Dim dlgMacros As Dialog
'    Set dlgMacros = Dialogs(wdDialogToolsMacro)
'    Application.Dialogs(wdDialogToolsMacro).Show
    SendKeys "(%{F8})", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "N", True
    SendKeys "{ENTER}", True
End Sub
If the current look in is something other than the normal template, it works. If it is already the normal template, it tries to delete the first macro in the list and generates a question. Still would prefer to use the dialog box arguments!

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Making changes to Word's macros dialog - arguments of dialog box

Post by HansV »

Again - weird. If I assign my or your version of the MacroListNormal macro to Alt+F8, it works correctly:

S0021.png

(Test is the only macro in my Normal.dotm)
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Charles Kenyon
4StarLounger
Posts: 596
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Making changes to Word's macros dialog - arguments of dialog box

Post by Charles Kenyon »

I made the mistake of assuming that if I assigned a macro to a keyboard shortcut that called the macro I would get recursion. I didn't test it.