Help in finding the next 'S'

B

Ben

Hi,
I have code that actually find the 1st 'S' of the document where it will
cut and paste to new document. Can i coded in vb that it will find the next
'S' and cut and paste instead.

With Selection.Find
.Execute FindText:="<????????>", MatchWildcards:=True,
MatchWholeWord:=True, Wrap:=wdFindContinue, Forward:=True
'MsgBox "!"
'Invoke the SaveAs box
With Dialogs(wdDialogFileSaveAs)
.Name = Trim$(Selection.Text)
.Show
End With

End With

Tks
regards,
Ben
 
D

Doug Robbins

Use this type of construction

Dim i As Long
i = 0
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="<????????>", MatchWildcards:=True,
Wrap:=wdFindStop, Forward:=True) = True
i = i + 1
If i = 2 Then
Exit Do
End If
Loop
End With
MsgBox Selection.Text


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

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