Expanded version of Find and Replace dialog

B

Bear

Does anyone know how to control (via VBA) whether the Find and Replace dialog
box appears in its compact or expanded version? I.E. I'd like to open the
dialog box but guarantee that the expanded version is displayed, as if the
More button had been clicked.

I've tried SendKeys (with and without DoEvents), but it won't work outside
of the VBE environment.

It would even be sufficient to set the option once per session, as Word
seems to remember whether the expanded or condensed version was last opened.

Bear
 
J

Jean-Guy Marcil

Bear said:
Does anyone know how to control (via VBA) whether the Find and Replace dialog
box appears in its compact or expanded version? I.E. I'd like to open the
dialog box but guarantee that the expanded version is displayed, as if the
More button had been clicked.

I've tried SendKeys (with and without DoEvents), but it won't work outside
of the VBE environment.

Did you try like this:

SendKeys "%m"
Application.Dialogs(wdDialogEditFind).Show

Note that
SendKeys "%m"
will cause a "Ding" sound if the dialog is already expanded...
 
B

Bear

Jean-Guy:

Thanks for responding. Yes, what I did is very close to that. Here is the
code in all its glory. The problem is that while this runs fine from within
the VBE, it does not work (the Alt+M never gets heard) when run from within
the document via keyboard shortcut. It does work if run from within the
document via toolbar button.


Sub FNRTest()

On Error GoTo Error

SendKeys "%(M)"

Dialogs(wdDialogEditReplace).Show
GoTo Done

Error:
MsgBox _
Title:="FNR Tool", _
Prompt:=Err.Description, _
Buttons:=vbInformation
GoTo Done

Done:

End Sub
 
J

Jean-Guy Marcil

Bear said:
Jean-Guy:

Thanks for responding. Yes, what I did is very close to that. Here is the
code in all its glory. The problem is that while this runs fine from within
the VBE, it does not work (the Alt+M never gets heard) when run from within
the document via keyboard shortcut. It does work if run from within the
document via toolbar button.

I don't know what to write...

I tried your code as is, I assigned a keyboard shortcut to the code (ALT-P)
and it always works as it should...

I am using Word 2003.
 
B

Bear

Jean-Guy:

Then we are, once again, baffled. Thanks for exploring this with me. I'll
continue to tease this problem at the back of my mind, but I don't have much
hope for finding a resolution.

The co-worker for whom I was attempting to create this macro experiences the
same behavior as do I. She also uses Word 2003, though I use Word 2000.
Neither of us can get the macro to run using a keyboard shortcut.

Bear
 
J

Jen

Can't you use the FindReplace command? Is there one like Overtype and
FileSaveDialog so it runs instead of the FindandReplace?
 
B

Bear

Jen:

I'm not certain I understand your suggestions. Yes, I can use the Edit >
Find and Edit > Replace commands. The object was to create a macro that would
always open the Find and Replace dialog boxes in expanded mode.

My co-worker always wants to use these dialogs in expanded mode, and has to
press Ctrl+H then Alt+M each time. (Or at least the first time in each
session.)

For example, she wanted a macro to attach to Ctrl+H that would open the
Replace dialog box in expanded mode.

Bear
 
J

Jen

Yes I use sendkey for Templates but FindReplace doesn't seem to work with
ALT M expanded.
 
K

Klaus Linke

Bear said:
Jean-Guy:

Then we are, once again, baffled. Thanks for exploring this with me. I'll
continue to tease this problem at the back of my mind, but I don't have
much
hope for finding a resolution.

The co-worker for whom I was attempting to create this macro experiences
the
same behavior as do I. She also uses Word 2003, though I use Word 2000.
Neither of us can get the macro to run using a keyboard shortcut.

Bear


Hi Bear,

Re:
Sub FNRTest()


If you call your macros "Sub EditFind()" and "Sub EditReplace()", they
should get called no matter how you do the Find (or Replace), whether using
any of the shortcuts, or from the menu, or some toolbar or context menu.
That way, you don't need to mess with the toolbar buttons and keyboard
shortcuts at all.

Regards,
Klaus
 

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