24 | 03 | 2017

VisibleVisual.com | Word VB Articles

Find Text

 In word you can use the function below to search for a specific text. This particulair function has a option to choose if the search is case sensitive or not. 

 

Function FindText(ByVal searchStr As String, Optional ByVal doMatchcase As Boolean = False) As Boolean

'****************************************
'*** Code from VisibleVisual.com ********
'****************************************
 
Selection.Find.ClearFormatting()

With Selection.Find
   
	.Text = searchStr
	.Forward = True
	.Wrap = wdFindContinue
	.Format = False
	.Matchcase = doMatchcase
	.MatchWholeWord = False
	.MatchWildcards = False
	.MatchSoundsLike = False
	.MatchAllWordForms = False
End With
	 
If Selection.Find.Execute = True Then
	FindText = True
Else
	FindText = False
End If
   
End Function
 
 
Sub TestFunction()

   MsgBox(FindText("VisibleVisual", True))
  
End Sub
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2206757
Latest Articles