text formatting

E

Edward

Hi everybody,
Im using the following code to genetare a text formatting
mystr= ' somthing
For x = 1 To 50 - Len(mystr)
mystr = mystr + " " + "."
Next
my problem is for different lenght of mystr even when i use truetype font
the results don't line up correctly

first text .............................1
seocnd long text ................2
altough we have the same number of characters in each line but 1 and 2 don't
line up correctly . any suggestions?
Thanks,
 
J

Jonathan West

Edward said:
Hi everybody,
Im using the following code to genetare a text formatting
mystr= ' somthing
For x = 1 To 50 - Len(mystr)
mystr = mystr + " " + "."
Next
my problem is for different lenght of mystr even when i use truetype font
the results don't line up correctly

first text .............................1
seocnd long text ................2
altough we have the same number of characters in each line but 1 and 2
don't
line up correctly . any suggestions?
Thanks,

Set a tab with a leader.

Start the macro recorder as described in the following article

Creating a macro with no programming experience using the recorder
http://www.word.mvps.org/FAQs/MacrosVBA/UsingRecorder.htm

Then type in a tab and then your number for the end od the line. Then go to
Format, Tabs. In that dialog, type in the position where you want that final
number to be, and select the kind of leader you want leading up to it.

Once the tab has been set, stop the macro recorder and take a look at the
code you have created. You can modify it as necessary. Take a look at this
article

How to Modify a Recorded Macro
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm
 
J

Jay Freedman

Hi Edward,

Have you ever heard about the difference between fixed-width and
proportional fonts? The trouble you're having is that your document uses
proportional fonts -- different characters have different widths -- so the
width of the text isn't determined just by the number of characters.

The way all word processors get around this is to set a tab stop at the
right end of the line, and insert a tab character between the text and the
number. Further, most of them (including Word) let you format a tab stop
with a "leader" character such as the dots you're trying to insert. So you
just insert a tab character, and the space is automatically filled in with
dots. Read http://www.word.mvps.org/FAQs/Formatting/SettingTabs.htm.

Finally, it looks like you're trying to create an index. Word has a built-in
feature for marking index entries and a field for building an index from
those entries. If that's what you're doing, look in the help file for "How
to make an index".

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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