How to call Find.execut

M

mjlaali

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?
 
M

macropod

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.
 

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