Guest_imported
New member
- Jan 1, 1970
- 0
I need help creating a macro in word which will check for a string of text, if found then it will print in a certain way, if not found it will continue with the macro. I hope someone can help me.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 04/15/02 by Justin G. Ezequiel
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "justin"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
Option Explicit
Sub HandleDifferently()
Dim oDoc As Word.Document
Set oDoc = ActiveDocument
With oDoc.Range.Find
If .Execute(FindText:="particular wording specific to document1") Then
MsgBox "handle as document1"
ElseIf .Execute(FindText:="particular wording specific to document2") Then
MsgBox "handle as document2"
ElseIf .Execute(FindText:="particular wording specific to document3") Then
MsgBox "handle as document3"
ElseIf .Execute(FindText:="particular wording specific to document4") Then
MsgBox "handle as document4"
Else
MsgBox "handle how?"
End If
End With
End Sub