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

Macro to Align multiple lines to a specific location? – MS Word

Status
Not open for further replies.
May 19, 2010
2
US
Hi all,

I’m trying to create a macro that would align multiple lines of text based on a specific location.

Basically I have a letter in a word document that places three lines of text near the right hand margin. The line in the center is the longest. I need to align the first characters in the two shorter lines above and below based on the position of the first character in the middle line.

For example:

Big
Sunny Afternoon
Picnic

These lines are not right aligned; the application that generates the letter just inserts spaces to position the text. Altering the application is not an option.

Using the example text above - I know that using selection.information I can find the position of the “S” in Sunny. Once I know that position, is there a way to place the other lines in the same position on the lines above and below?

Any suggestions on functions or approaches would be appreciated.
 



Hi,

Can this not be done using a custom TAB stop wlth Left Align?

I do not understand why are claiming that "These lines are not right aligned." It is obvious that they are NOT. They are LEFT ALIGNED.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Use the same Style for each paragraph. Done.

Gerry
 
Skip, your are right.... er.. left ;)
Thanks for the suggestion.

BTW- once I set the tab, is there a way to make sure the text is a aligned with the tab? Unfortunately I have to deal with all sorts of junk white space that get put into the letter.

Thanks for the suggestion fumei.

Gives me some things to think about. I'll let you know if I come up with something.
 


I would suggest doing an Edit > Replace.

Replace [SPACE][SPACE] with [SPACE]

Repeat until there are no replacements made.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm confused - if the creating application aligns with spaces, why does it not put the same number of spaces on each line? That aside, what is the ultimate purpose of the exercise? If you're just creating a one-off document, it is probably easiest to count the spaces on the middle line and adjust the first and last lines to have the same number.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top