find matching format

D

Duas Quartunciae

I am trying to use the find object to find text matching format of
other text.

I thought I could do that just by (for example)

selection.find.font = activedocument.range(12,13).font

This does not find anything. It does not find the characters I used as
a basis for identifying the font to search for.

With Selection.Find
.ClearFormatting
.Font = ActiveDocument.Range(12, 13).Font
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchByte = False
.CorrectHangulEndings = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
.Execute
If Not .Found Then
MsgBox "Find fails"
End If
End With

On the other hand, if I set selection.find.font.bold = true, or
something of the kind, it will find bolded text.

Is it possible to just set a font on the find object from some other
font object, and then search for matching formats?

Cheers -- Chris
 
H

Helmut Weber

Hi Duas,

IMHO, you can only search for specific font.properties,
not for something that matches a font.object in all details.

However, the following might help:

Sub Macro33ab()
Dim rTmp As Range
Set rTmp = Selection.Range
Dim oFnt As Font
Set oFnt = Selection.Range.Font
rTmp.Collapse direction:=wdCollapseEnd
With rTmp.Find
.Font.Bold = oFnt.Bold
.Font.Name = oFnt.Name
.Font.Color = oFnt.Color
If .Execute Then
rTmp.Select
End If
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