Link to home
Start Free TrialLog in
Avatar of Cornelia Yoder
Cornelia YoderFlag for United States of America

asked on

Create MSWord style for text table

Given some text, I want to convert it to a 2 column table (tab separator) with no borders.  Is there a way to create a "style" or some such thing so I can do this repeatedly without having to go through the entire process each time?
Avatar of yobri
yobri
Flag of United States of America image

So I can understand this better, you have lines of text in a Word document that are separated by a single tab.

You would like to have a borderless table inserted in place of this text where the first portion of text before the tab is in the first (left) cell of the table and the second portion of text after the tab in the second (right) cell of the table.

Is this right? If so...

- Are the lines of text that are separated by a tab all on a single line?

- Would (you accept) a macro-based solution work for your objective?
Avatar of Patrick Matthews
Yodercm,

If you are interested in a macro-based solution, I have something that may interest you.

Patrick
Avatar of Cornelia Yoder

ASKER

Yes to your description, and the line of text may wrap but it's all one long line of text.  It looks like this

2N (tab) Description of the 2N ....yada yada

3H (tab) Description of the 3H .... yada yada

I want it to show as

2N            Description which may
                be more than one line
                like this is.

3H            Description etc.



So far the only way I have found to do this is with a table, and it's a pain to create a lot of tables and remove the borders.  Any mechanism where I can highlight the text, click a button or command and have it formatted like that would be wonderful.

I know nothing about macros in msword, but if it's tolerably easy to do, would be ok.

Sorry it took so long to get back to you.

As long as you are using tab as the column delimiter, and you want to convert the current selection to a table, add a new module to your VBA project and add this:

Sub MakeATable()

    Selection.ConvertToTable Separator:=wdSeparateByTabs

End Sub

Open in new window


To execute, just select the text you want to convert, and hit F8 to bring up the run macro dialog.
"...add a new module to your VBA project..."

I have not the slightest idea what this means nor how to do it.

By the way, this will be used in Word 2003, if that matters.
The version should not matter.  Try this:

1) Open Word

2) Hit Alt+F11 to get to the VB Editor

3) In your project explorer (it should be docked to the left of your screen), look for "Normal", which will be your normal template.  Right click it, and select Insert / Module from the popup menu

4) Paste the code I gave you in that new module, and hit Ctrl+S to save

Now, whenever you are in Word, select the range you want to convert to a table, hit Alt+F8, and select MakeATable from the dialog box.
Ok, that worked beautifully to make the table!  Is there a way I can preset the column widths (or other properties of the table)?   I would like the first column to be about 8 characters wide and the rest of the page width for the second column.
Yes, other properties can be set as well.

Please go ahead and list out your complete requirements.  I probably won't get to it until my tonight (US Eastern time).
That should be it.  Perhaps you would give me a reference to a tutorial or manual for this stuff so I could continue to do such things on my own?
By the way, can this be set on a single key, like a hotkey sort of thing?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If there is a way to do a single hotkey to run this macro, I'd appreciate knowing how to set that up, otherwise this is exactly what I needed.  

Thank you very much for your time to write this and explain it to me!
Got it!  Thanks so much :)