Detect garbage character?

E

Ed

The report output of an ancient proprietary database (read through PASCAL)
gives a text file with a garbage character at the beginning of every line
(each line being a new paragraph). I'd like to do a Find/Replace to get rid
of all of them, but can't seem to get Word to recognize this character.
(It's the lower case y with two dots when Show/Hide is clicked; it prints
and views otherwise as a square.)

I tried ASC, and it returned a character code of 0, but a Find/Replace for
this replaced every space in my document! Does anyone have any other
suggestions? (I did write a macro that crawled down every line and deleted
the first character, but that seemed like the hard way to do it!)

Ed
 
P

Peter Hewett

Hi Ed

I'm not sure is you've tried this already but just copy the unwanted
character in the document and then paste it in to Find dialog.

If that does not work, please post again.

HTH + Cheers - Peter
 
E

Ed

Hi, Peter.
I'm not sure is you've tried this already but just copy the unwanted
character in the document and then paste it in to Find dialog.

If that does not work, please post again.

Yes, I did that. It replaced 51,948 items - all the characters AND *EVERY
SINGLE SPACE*!

Also, I was hoping to put this into a macro - which I could, I guess, by
selecting and putting Selection.Text into a string for the .Find.

Ed
 
P

Peter Hewett

Hi Ed

LOL - 51,948!!!!

A couple more ideas. Select JUST ONE of the weird characters and start up the
VBA IDE, and display the Immediate window. Now type:

?LenB(selection.Text)
?AscW(selection.Text)

And post back what each statement returns.

Hopefully once we really know what you have in your document we can do
something about it!

Cheers - Peter
 
K

Klaus Linke

Hi Ed,

Try .Text=Chr(0) in your Find/Replace macro.
I think it'll work.

Regards,
Klaus
 
E

Ed

Thanks for the input, Klaus. But after I got the "0" return from ASC, that
was the first thing I did. It deleted every space in the document.

Ed
 
E

Ed

LenB(Selection.Text) = 2
AscW(Selection.Text) = 0

I also checked the regular space character - AscW returns 32, so I don't
know why a Find/Replace Chr(0) deletes the spaces, too.

Ed
 
P

Peter Hewett

Hi Ed

I can't get Word to do a .Find on a null character (asc(0)). Not even if I
cut and paste it into the Search and Replace dialog! Cool huh!

Looks like iterating the paragraphs collection is the way to go.

Cheers - Peter
 
J

Jonathan West

Peter Hewett said:
Hi Ed

I can't get Word to do a .Find on a null character (asc(0)). Not even if I
cut and paste it into the Search and Replace dialog! Cool huh!

Type ^0000 into the Find What box
 

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