Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with the "find" object.....

Status
Not open for further replies.

nesplb

Programmer
Jul 29, 2003
109
NO
Hi!
I've mant to make a makro that shall search for all the words with the font "Arial" and "Arial Black". To do this I have to use the find-object. So far I've got it to work with one font, but I havent got it to work with two fonts.
Here is my code so far:

Code:
    Dim tjRange As Range
    Set tjRange = Selection.Range
    
    tjRange.Find.ClearFormatting
   
    With tjRange.Find
    
        .Text = ""
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False

        .Font.Name = "Arial Black"
        
        End With

tjRange.Find.Execute
If I apply
Code:
.Font.Name = "Arial"
under
Code:
.Font.Name = "Arial Black"
in the code, it will still only search for one of the fonts (the last one that is mentioned)
Can anyone help me with this problem?

-If this isn't possible, is there any possibility to search for text that is not black in the find object? The text I want to find is coloured in different colours, but not black....you see?

Thanx!

Pål


Pål Nesteby

PDC-Tangen
Norway
 
you could search for all the Arial text then within the results look for all the Not Arial Black text
try putting in
.Font.Name = not"Arial Black"

i have not tested this but see what happens

 
Thanx for your time but it only gives the error message: "Type mismatch"

Pål Nesteby

PDC-Tangen
Norway
 
Any reason why you don't just loop through your document twice, looking for "Arial" the first time and "Arial black" the next time? You could put any duplicated code into its own sub, to minimize the length of code you need to repeat.


Rob
[flowerface]
 
Exactly what I needed!
Sometimes the easiest way is the best!!!



Pål Nesteby

PDC-Tangen
Norway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top