Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

find matching format

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Duas Quartunciae - 24 Jan 2008 06:13 GMT
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
Helmut Weber - 24 Jan 2008 12:52 GMT
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

Signature

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)

Duas Quartunciae - 28 Jan 2008 08:08 GMT
Thanks very much! -- Chris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.