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

Word97 - Alignment Problem

Status
Not open for further replies.

SHardy

Programmer
May 9, 2001
231
GB
I am trying to put together a mail merge letter within Word97. However, I am having problems with aligning information at the top of the page.

I want to display useful information at the top of the page, like this:

Client's Company: ACME Inc.
Helpline Number: 01234 56789
Reference Number: 12345

I want the text to align together at the colons, with the longest field to be right aligned.

It seems that the best/ easiest way of aligning at the colons is to enter the text & fields into a table. However, the problem that I then have is that the company name can vary quite drastically in length. Is there anyway to make the column widths automatically adjust to fit the contents, while also keeping the whole table right aligned to the margin?

Any alternatives to acheiving what I want would also be appreciated.

Thanks,
S
 
SHardy

Select ALL THREE LINES

Format 3 tabs, RIGHT, CENTER, LEFT, for instance at 3", 3.2", 3.4"

Each line must be PRECEEDED with a [TAB], [TAB] on ither side of the colon (ie each line has THREE TABS)

Skip,
[sub]
[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue][/sub]
 
An alternative solution is to use a decimal aligned tab. The rows will align at the colon. The only minor problem is that any punctuation character (except the regional thousands seperator) will align at the decimal tab. SO the first row will try to align at the apostrophe in client's. You might be able to simplify this by sacrificing grammatical correctness by just using 'Client Address'.

Right align row 2 (the longest row) using a right aligned tab. Then set a decimal tab in all other rows so that the colons aline.

Regards: tf1
 
oops. My TAB did not display...

Each line must be PRECEEDED with a TAB, TAB on either side of the colon (ie each line has THREE TABS)


Skip,
[sub]
[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue][/sub]
 
tf1:

How do you set a "decimal tab"?

Skip:

Could you explain in novice terms?


Sorry, don't really do much in Word. Need instructions to be as basic as possible.

Thanks.
 
For clarity, I am using merge fields, so it would initially look something like:

Client Name: <<ClientName>>
Helpline Number: <<Helpline>>
Reference Number: <<RefID>>

until the data is merged. At which point the client name can vary drastically in length. Hence the problem with alignment.

Are the above solutions still relevant?
If so, hand holding required.

Thanks
 


View/Ruler -- this makes the margin/tab bar visible.

SELECT all the lines you want to format for tabs.

To the LEFT of the bar is an ICON that TOGGLES thru the available margin and tab objects. Toggle to get to the one that you want, then point to the location in the margin/tab bar where you want the tab. You want a LEFT, CENTER, & RIGHT tab at like 3, 3.2 and 3.4.

If I use <T> for a tab character then...
[tt]
<T>Client Name<T>:<T><<ClientName>>
<T>Helpline Number<T>:<T><<Helpline>>
<T>Reference Number<T>:<T><<RefID>>
[/tt]


Skip,
[sub]
[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue][/sub]
 
There are two ways to set tabs. You can use the Format, Tab dialog: type in the position you want the tab, then click on the Decimal option and OK the dialog.

The best way is to click on the little box at the left hand end of the Ruler. By default, the box will have a capital L symbol, which represents a Left Aligned tab.

If you click on the box, the symbol will toggle through the Tab type options from L for Left, a T representing Centre, a reversed L from the right-aligned and then a T. symbol representing a Decimal Tab.

Whilst the desired tab type is displayed in the box, if you click the mouse in the lower part of the ruler, it will place the appropriate tab at that position.

You can move the tab along the ruler usng the mouse. It normally moves in increments determined by the invisible grid set in the Drawing layer. You can override the grid by holding down the Alt key whilst sliding the tab along the ruler and position it very accurately.

The later option is the quickest way to insert and adjust a tab. If you want to remove a tab, just drag it off to the far right or left of the ruler and it disappears when you release the mouse.

Regards: tf1
 
Thanks for the help, however after trying both methods, it doesn't really help me. It's not allowing for the fact that the length of the data can vary a great deal (remembering that the longest should be right aligned to the margin).

<<Helpline>> will contain a phone number, formatted with spaces.

<<RefID>> Will contain a numeric reference from 1 to 6 digits (most likely 5 or 6)

<<Client Name>> Is the name of the company. This can vary a great deal. We have some as small as 3 characters, and others as big as 45 characters.

When the data for the letter holds a long company name, then this row would need to be right aligned, with the other two rows aligned at the colon.

When the data for the letter holds a small company name, it is likely that the phone number would be the longest field. Therefore, in this instance the phone number should be right aligned, with the other two rows aligned to it at the colons.

I don't know how clearly this reads.

Am I expecting too much of Word?
 
Ahhhhhh,

The LAST TAB needs to be a RIGHT TAB located on the RIGHT MARGIN.

Skip,
[sub]
[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue][/sub]
 
Thanks, but again this does not allow for the change in size of the merge fields. For this I have to leave a gap between the colon and the field big enough for the largest possible data. This then leaves a huge gap for smaller company names.
Also this then either leaves all 3 fields right aligned, or the fields not aligned together at the colon.

I'll try another example of what I am after:

Client Name: A Sample Client Name|
Helpline Number: 01234 56789 |
Reference Number: 12345 |



The vertical lines represent the right margin. Note that the colons are aligned together (as well as I could anyway). The text either side of the colons all lines up against the colons.

Remember that the text after the colons can change in length.

This is sort of how I would like it aligned for ALL records.
Longest field right aligned to right margin.
All colons aligned together.
All text and fields lined up against the colons.

I'm not convinced that it is possible to do this by using TAB points, as these would need to be dynamic, rather than static.

I hope I have now made this crystal.

Any further comments or suggestions would be very welcome.
 
You can use a fixed decimal tab but you will need to position it so that there is room for the longest right-group to fit between the tab point and the margin.

Having the colons align AND the group right-flushed is gonna be difficult.

Is there a possibility you could put them into a three row, one column table, where the table is set to AutoFit to Contents, is right aligned and has a decimal tab set. Decimal tabs in tables don't require a Tab to be inserted, Word will Automatically align the colons to the decimal tab.


Regards: tf1
 
I thought about using a table that autofits to contents. However, as far as I can see you can't tell it to always autoformat when the contents change. It seems to require the user to actually carry out the AutoFit command.

I thought about using VBA to tell it to AutoFit. However, two problems:

1) Couldn't find a suitable Event to trigger the macro. Was expecting something like, Page.OnFormat.

2) As far as I could see, there was no easy way to identify and select the table. I was expecting Word to have a name for each table on a document (e.g. "Table1", etc).

Sorry for all the questions. I have never really had to do much in Word. Excel and Access are my strengths.

All help is appreciated.

Thanks
 
I'd use the table approch. Why can't the text wrap in the cell?

Skip,
[sub]
[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue][/sub]
 
We don't want the text to wrap, as it looks quite messy.

The format that I described above seems to be the preferred way forward, if it's going to be possible.
 
possible events to fire table autoformat: use Document_Open; use Document_Close; use FileSave; use a macro & put as button on toolbar

identify table: assume there r tables u do NOT want to autoformat, put bookmark in table u DO want action. if not matter, loop thru all tables (no need bookmarks); if not many tables, and can count, hard code the table number (not good, what if doc changes?); if table has caption, use that.
 
Any chance of example code?

Not sure that the Document_Open event will work, as it opens initially unmerged and takes a couple of seconds to merge the data. May give it a go on this event anyway. I suppose it may be possible to add a timer function so that the code runs 2 or 3 seconds after opening?
 
I'm playing with the macro idea. However, the AutoFit Option didn't work. As the text was already wrapped within the cell, it stayed wrapped rather than going onto one line.

I tried widening the table to begin with. The autofit worked, but the table was not aligned to the right margin.

Is there any way to:

1) Tell Word NOT to wrap text within a table?
2) Align a table to the documents right margin?
 
what version u have? better to use a table style - that way can format columns as u want.
 
I'm not exactly sure how I did it, but I have managed to get the AutoFit function to work. It now keeps it on one row, keeps the table aligned to the right margin and increases the column width (towards the left).

I have also added the following code:

Sub Document_Open()
PauseTime = 4
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Selection.GoTo What:=wdGoToBookmark, Name:="InfoTable"
Selection.Find.ClearFormatting
Selection.Cells.AutoFit
End Sub

Seems to work. Like I said, I am not exactly sure how I did it. So the test is going to be recreating it in the required documents.

I shall post again once I am sure of exactly how I did it.

Thanks

BTW, version is Word97
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top