I need IS NOT (<>) operand for Font.Name

J

jg0017

In the sub below I need to make line six return 'true' on any OTHER font that
the one listed. I've tried all the normal operands and nothing works.

The sub purpose is to replace all fonts with one single font.

Thanks,

Mike


Sub ReplaceFont()
With Selection.Find
' Clear all previously set formatting for Find dialog box.
.ClearFormatting
' Set font to Find for replacement.
.Font.Name = "Arial"
' Clear all previously set formatting for Replace dialog box.
.Replacement.ClearFormatting
' Set font to Replace found font.
.Replacement.Font.Name = "Times New Roman"
' Don't find or replace any text.
.Text = ""
.Replacement.Text = ""
' The following parameters must be set as follows
' to find only text formatted for the specified font.
' .Forward = True
' .Wrap = wdFindContinue
' .Format = True
' .MatchCase = False
' .MatchWholeWord = False
' .MatchWildcards = False
' .MatchSoundsLike = False
' .MatchAllWordForms = False
End With
' Perform the find and replace.
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
G

Greg Maxey

I don't think you can do it that way.

Maybe:

Sub ScratchMacro()
Dim oPar As Word.Paragraph
For Each oPar In ActiveDocument.Range.Paragraphs
oPar.Range.Font.Name = "Times New Roman"
Next oPar
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