Determining if Text Exists in active document

L

LA Lawyer

I want to determine if a specific string of text (e.g., "String of Texts")
exists on the first page of the document on the screen.

How is that done?
 
M

macropod

Hi LA Lawyer,

Try something along the lines of:
Sub FindOn1stPage()
Dim StrFind As String
StrFind = "My Text"
With ActiveDocument.Content.Find
.ClearFormatting
.Text = StrFind
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
If .Found = True Then _
If Selection.Information(wdActiveEndPageNumber) = 1 Then _
MsgBox Chr(34) & StrFind & Chr(34) & " Found on First Page"
End With
End Sub
 

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