Dialogs(wdDialogEditReplace).Show

R

Richard

I hope this is the right newsgroup, if not please point me in the right
direction.

Could anyone tell me why Dialogs(wdDialogEditReplace).Show works but
MsgBox Dialogs(wdDialogEditReplace).Show doesn't (raising error 5524, which
as far as I can gather is undocumented)?

Which leads me to the $xxxx dollar question: is there any way to
programatically retrieve the return value of .Show? (i.e. the button/action
the user performed)
All the code I've seen puts an On Error Resume Next before the .Show line,
which would suggest that the answer to above is 'No'!

Alternatively, is there a Win API workaround (possibly with callback
function) that calls Word's F&R dialog?

Before you ask, I've already tried all the very erratic Sendkeys ways of
calling Word's F&R dialog. Sendkeys with Ctrl-H from a Public Sub itself
called by a keybinding does not work, (Sendkeys Alt-e, e from same Public
Sub does, but some of my users have already remapped Alt-e for their own
purposes). I know I can .Execute my Selection.Find etc, but I really need to
be able to "intercept" it via the dialog. If there's no way of
programmatically "hooking in" to Word's F&R dialog, then I suppose the only
viable alternative is to create one's own dialog with a UserForm (kludgy and
slower at best, no?)?

Regards

Richard
 
D

Doug Robbins - Word MVP

Tell us what you are really trying to do, rather that how you have not been
able to achieve it.

On Error GoTo EndThis
With Dialogs(wdDialogEditReplace)
.Find = "Blue"
.Replace = "Red"
If .Show = 0 Then
MsgBox "The use did not execute the command"
End If
End With
EndThis:

--
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
 
R

Richard

Thanks Doug, today it's working.
(i.e. If .Show = , Retval = .Show etc all work today, after shutting down
the computer last night, go figure!). That said, I'm still curious as to why
all the "MVP" code I've seen on the net puts On Error Resume Next before
calling this dialog, but no matter. "Ours not to reason why" apparently
(given the 'tone' of this newsgroup), ours but to say what we are trying to
do : - )

Talking of which, apart from the above (retrieving the return value of
..Show), I'm also trying to do the following:

1. Control wdDialogEditReplace, i.e. make it modeless. The .Show method
only takes Timeout as argument. There appears to be no way to make it
modeless (the Find tab is dimmed). I would like it to be modeless (as it is
when called by Word's user interface) to give the user the option of
clicking the Find tab (hence my query about possible Win API workarounds,
I'm still takers, should you know of one)

2. Configure wdDialogEditReplace before ".Show" ing it , i.e. force it to
show More (perhaps I could try a Sendkeys to automatically develop the
'More' options?). Since you are no doubt going to say "what are you trying
to do", I need to do this to prompt the user to consider whether or not they
need to check "Match case" and/or "Match whole word", which are critical
parameters in the translation-related routine I'm writing.

Of the two, number 1 (the modeless issue) is by far the most important to
me. Why is this dialog modal when called by code but modeless when called
"'normally" by the user? Where's the logic?

Thanks for any enlightenment

Richard
 

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