Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Character code for en space and em space

Posted on 2011-03-24
4
829 Views
Last Modified: 2012-05-11
Does anyone know the character codes for an en space and an em space in VBA for Word?
0
Comment
Question by:Fi69
  • 2
  • 2
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35206654
I don't believe that there is on, since with proportional fonts, it would be rather redundant.
You could use a couple of spaces for the n, and three or four for the m space, but it wouldn't be precise, and would depend on the font and the letter case.

If you need character to align vertically, there are other ways of achieving it, including tabs and fixed-width fonts such as Courier New.
0
 

Author Comment

by:Fi69
ID: 35211328
Okay, thanks Graham. No I wanted to achieve that gap without using spaces, just separating telephone and fax that appear on the one line. I'll just use two spaces. I still use them often via Insert > Symbol and hoped to do via code.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 125 total points
ID: 35211560
Sorry Fi,

If you can find the symbol that way, then I was wrong. I have only ever been able to find a normal space and a non-break space, but I was looking in the wrong place.

Try this:


Sub InsertSpaces(rng As Range)
    rng.InsertAfter ChrW(8195) 'm space
    rng.InsertAfter ChrW(8194) 'n space
End Sub

Open in new window

0
 

Author Closing Comment

by:Fi69
ID: 35211591
Perfect - thank you!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question