Cornelia Yoder
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?
Yodercm,
If you are interested in a macro-based solution, I have something that may interest you.
Patrick
If you are interested in a macro-based solution, I have something that may interest you.
Patrick
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.
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:
To execute, just select the text you want to convert, and hit F8 to bring up the run macro dialog.
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
To execute, just select the text you want to convert, and hit F8 to bring up the run macro dialog.
ASKER
"...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.
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.
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.
ASKER
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).
Please go ahead and list out your complete requirements. I probably won't get to it until my tonight (US Eastern time).
ASKER
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?
ASKER
By the way, can this be set on a single key, like a hotkey sort of thing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
Thank you very much for your time to write this and explain it to me!
ASKER
Got it! Thanks so much :)
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?