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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and Replace Special Characters 2

Status
Not open for further replies.

harky

Technical User
Oct 29, 2001
39
GB
How do I find and remove EN spaces from a Word 97 document? I'm pretty new at this, so any help would be appreciated. Thanks for your time
 
Have you tried Edit > Replace > More > Special?
 
if You would like to do things like that (create code) in the future try to record a macro (menu path: Tools/Macro/Record New Macro), and do steps you want.

i recorded the task you ask for and get the following code:

Sub Macro1()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " ^p" 'a space and an "ENTER"
.Replacement.Text = "" 'change to
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

ide
 
I've tried looking for EN spaces in special in the find box, but it only has EN dashes. I think I need to do a search for the Character code or ASCII code, but I'm not sure what the code is, or how to go about this. Can anyone help?
 
I am not sure wnat an EN SPACE is.

^s - Nonbreaking space
^w - White space

If you can select and copy the character to the clipboard, you could use this code to return the ASCII value.

Dim sChar As String
sChar = InputBox("Enter the Char")
MsgBox Asc(sChar)

If this returns a good value, I would suggest using ide's method for replacing them.
 
Still no joy, tried all of these. An En space is a space the same width as an EN dash. It can be inserted through the Insert>symbol>special characters tab, where you can also assign a keyboard shortcut. Word seems to just reconise it as a space, so when I search and replace, it strips out all the spaces, which is not what I want. I tried running the code posted by dsi but it returns the same value as a normal space, 32. Any other suggestions?
 
Apparently the en dash and the en space both return the same ANSI code and that is why this isn't working for you. Microsoft has confirmed this to be a bug (Refer to their Knowledge Base article: Q136396) Neil Konitzer, President
Freisoft
 
ChrW(8194) will give you the EN space character
ChrW(8195) will give you the EM space character

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(8194)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top