From: mjlaali on
I am developing a Word Automation program using MFC and I want to call
"execute" function of "Find" object, but since it takes lots of VARIANT*
parameters and I don't know how to create a VARIANT* variable proper to each
of the input parameters, I can't call it. Is there anyone who could help me
please?
From: macropod on
Hi mjlaali,

In a Find/Replace operation, you can set most of the parameters via Find. For example:

Sub Find_Replace()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "1234"
.Replacement.Text = "5678"
.Forward = True
.Wrap = wdFindStop ' wdFindStop (0); wdFindContinue (1); wdFindAsk (2)
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceNone 'wdReplaceNone - (0); wdReplaceOne - (1); wdReplaceAll - (2)
End With
End Sub

There's plenty more 'Find' parameters too, covering such things as the font formatting, Word Style and so on. You can access these
via Word's vbe, where you can also use the object browser to get the values for and of the 'wd' contstants for any parameters you're
interested in. Word's vba helpfile has further information also.

For your purposes, you'll probably need to call the 'Wrap' and 'Replace' parameters with the numeric values, as indicated in the
comments on the corresponding lines above.

--
Cheers
macropod
[Microsoft MVP - Word]


"mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message news:3139F106-411A-4DCF-84C3-0FD762D69042(a)microsoft.com...
>I am developing a Word Automation program using MFC and I want to call
> "execute" function of "Find" object, but since it takes lots of VARIANT*
> parameters and I don't know how to create a VARIANT* variable proper to each
> of the input parameters, I can't call it. Is there anyone who could help me
> please?