convert space to non-breaking space

D

Dave Lett

Hi Daniel,

I think you can use something like the following:

Selection.text = Replace(Selection.text, " ", Chr(160))

HTH
 
J

Jay Freedman

Hi, Daniel,

If you're using Word 2000 or later, you can use the line

MyString = Replace(MyString, " ", Chr(160))

In Word 97, you'll need a For..Next loop to go through the string, changing
each space character to Chr(160).
 
D

Daniel Friedman

Regarding the two helpful replies I've received (thank
you!)...how did you know that Chr(160) specifies non-
breaking space? That is, if I should need to look up
something similar, like non-breaking hyphen, how can I
determine that character's code?

--daniel
 
J

Jonathan West

Daniel Friedman said:
Regarding the two helpful replies I've received (thank
you!)...how did you know that Chr(160) specifies non-
breaking space? That is, if I should need to look up
something similar, like non-breaking hyphen, how can I
determine that character's code?

Type the character you want to check into a document. Select it, and then
open the VBA editor. In the immediate window, type the following

? Asc(Selection.Text)

You'll get the character code back.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
L

Larry

If you want the ability to do this regularly, make a macro of it. This
will display a message box showing the character code of the selected
character or of the character following the insertion point. Very
handy.

MsgBox Asc(Selection.Text), , "Character Code"


Larry
 

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