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!

Searching Word for something NOT there.... 1

Status
Not open for further replies.

GComyn

Programmer
Jul 24, 2001
177
US
I've been doing alot of formatting with Word (I download books, reformat them for printing, then print them out)... but I also format them for HTML viewing...

What I'm trying to do is find a paragraph mark that does not have a Less than sign after it...

something like

find ^p and not "<"

and then it would search for every ^p, then test the next character to see if it was "<" and stop when it isn't...

I guess I should just program it.. but I was wondering if there was already something out here that would work.. and I can't seem to find it...

any help is appreciated...

GComyn
 
Ok... I did a down_and_dirty piece of code to help... what I'm really looking for is something like the find/replace dialog, something that will stay up while I edit the "found" string...

or go ahead and replace the string with another if I decide...

here is the code that I threw together..

Code:
Sub Finding_Not()
    Dim strFindWhat As String
    Dim strFindNot As String
    
    strFindWhat = InputBox("What is the character(s) to search for?", "Find What")
    strFindNot = InputBox("What is the character(s) that should be there?", "Find Not")
    Selection.find.ClearFormatting
    Do Until Selection.find.Execute(findtext:=strFindWhat, Forward:=True, Wrap:=wdFindContinue) = False
        Selection.MoveRight unit:=wdCharacter, Count:=1
        Selection.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
        If Selection.Text <> strFindNot Then
            Exit Do
        End If
    Loop
End Sub

if anyone has something better, I'd appreciate you showing me where it is or sending it to me... we can talk about where to...

GComyn
 
Hi GComyn,

You could use a wildcard search in Word using:
^13[!<]
for the find expression. No vba required, though you could do the same thing with vba.

Cheers

[MS MVP - Word]
 
Unfortunately, I just tried that, and it doesn't work for me....

I'm using MS Word 2002... maybe I need to change an option or something, but I don't think so, because it was searching for each character... and since I sometimes need to search for the characters [, ], and !, if I wrote a vba macro to use those as special characters, I'd also have to write in an escape code to tell when I wanted to find them.

thanks for you suggestion, though...

GComyn
 
Ok... didn't know about that option... and didn't really look at the options to begin with...

It works.. now I can put it in my 'formatting' code.

THANK!!!

GComyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top