H
Helmut Weber
Hi everybody,
starting with the question from Tony Logan
"stop selection when finding certain font"
I thought, I could come up with a simple solution.
However, when searching for "Arial",
nothing is found.
Works well with "Arial Black" or "Arial Narrow"?
Any ideas?
Sub test7568()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
.Text = ""
.Font.Name = "Arial" ' no way
'.Font.Name = "Arial Narrow" ' alright
'.Font.Name = "Arial Black" ' alright
.Format = True
While .Execute
rDcm.Select
Wend
End With
ResetSearch
End Sub
'----
Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
' plus some more if needed
.Execute
End With
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
starting with the question from Tony Logan
"stop selection when finding certain font"
I thought, I could come up with a simple solution.
However, when searching for "Arial",
nothing is found.
Works well with "Arial Black" or "Arial Narrow"?
Any ideas?
Sub test7568()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
.Text = ""
.Font.Name = "Arial" ' no way
'.Font.Name = "Arial Narrow" ' alright
'.Font.Name = "Arial Black" ' alright
.Format = True
While .Execute
rDcm.Select
Wend
End With
ResetSearch
End Sub
'----
Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
' plus some more if needed
.Execute
End With
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"