replace unknown characters in a variable

M

Mike Archer

Hello - I used the following to set a variable equal to a whole document:
WholeDocumentString = ActiveDocument.Sections(1).Range
That works just fine... but I need to remove all non whitespace and all
non-keyboard characters. I use this:
WholeDocumentString = Replace(JavaScriptArray, Chr(9), " ")
WholeDocumentString = Replace(JavaScriptArray, Chr(10), " ")
WholeDocumentString = Replace(JavaScriptArray, Chr(13), " ")
That works fine for linefeeds, carriage returns, and tabs. But there are
still some unknown characters from a table. These characters occur where the
table columns are located. How do I replace those with a space?
 
S

Stephen English

Mike
How about reading it character by character and debug.print if it is not
within the range of characters for a-z, A-Z, 0-9. When you find the
offending character, you can then replace it as with your Chr(9) etc.
Just an idea - hope it helps
REgards
Stephen
 
K

Klaus Linke

Hi Mike,

Chr(7).
It's from the end-of-cell and end-of-row markers, Chr(13) & Chr(7).

Regards,
Klaus
 
M

Mike Archer

YES! That hit the spot.
--
Thanks,
Mike


Klaus Linke said:
Hi Mike,

Chr(7).
It's from the end-of-cell and end-of-row markers, Chr(13) & Chr(7).

Regards,
Klaus
 

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