Word find.selection on formatted text?

V

vonclausowitz

This Q was posted earlier in microsoft.public.vb.general.discussion.

Veign,

Saw the code, looks good, tried it but couldn't get it to work, need a
little hand.

Do While rstNaam.EOF = False

For Each myStoryRange In ActiveDocument.StoryRanges
With myStoryRange.Find
.Text = rstNaam("zoekstring")
.Replacement.Text = ""
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Do While Not (myStoryRange.NextStoryRange Is Nothing)
Set myStoryRange = myStoryRange.NextStoryRange
With myStoryRange.Find
.Text = rstNaam("zoekstring")
.Replacement.Text = ""
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Loop
Next myStoryRange

||||||||||||||||||||||||||||||||||| next part won't work
|||||||||||||||||||||||||||||||||||||||||||||||||||

If myStoryRange.Find.Execute = True Then
sTempNaam = rstNaam("bestandsnaam")
Exit Do
End If
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

rstNaam.MoveNext
Loop

How should I go about?
I want to search the doc for the rstNaam("zoekstring"), and when it is
found
this will become the name of the document:

With wdApp
With .Dialogs(wdDialogFileSaveAs)
.Name = gDiskLetter & sTempNaam & Format(Date,
"YYYYMMDD")
.Show
End With
End With

like this.

Marco
 
T

Tony Jollans

Of course the text won't be found - you've just been all through the
document replacing it with nothing.

Or is there some other error?
 

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