tla
10-25-2007, 11:56 AM
OK, I have a task I want to accomplish that I have approached a couple ways and failed.
I have a table in a word document. It is 2 columns, one row. Above that table i have a list of words like so:
{MACROBUTTON Populate_Table System 1}
{MACROBUTTON Populate_Table System 2}
{MACROBUTTON Populate_Table System 3}
{MACROBUTTON Populate_Table System 4}
{MACROBUTTON Populate_Table System 5}
With the field codes toggled so only the System X is displayed. This is a test, in real life the system X would be replaced by acutal system names (which there are 20 or so).
When the system name is clicked, the Macro runs, and a line is added to the table in the document. This is the Macro
Sub Populate_Table()
mySystem = Selection.Text
ActiveDocument.Tables(1).Rows.Add
myRows = ActiveDocument.Tables(1).Rows.Count
ActiveDocument.Tables(1).Rows(myRows).Cells(1).Select
Selection.Text = mySystem
End Sub
Of course it popluiates the first cell of the new table row with an end of line box
How can i get the name of the system (which is variable in length) into the mySystem variable ? I tried passing a variable to the subroutine
{MACROBUTTON Populate_Table(1) System 1}
{MACROBUTTON Populate_Table(2) System 2} etc
but that doesn't seem to work.
I have a table in a word document. It is 2 columns, one row. Above that table i have a list of words like so:
{MACROBUTTON Populate_Table System 1}
{MACROBUTTON Populate_Table System 2}
{MACROBUTTON Populate_Table System 3}
{MACROBUTTON Populate_Table System 4}
{MACROBUTTON Populate_Table System 5}
With the field codes toggled so only the System X is displayed. This is a test, in real life the system X would be replaced by acutal system names (which there are 20 or so).
When the system name is clicked, the Macro runs, and a line is added to the table in the document. This is the Macro
Sub Populate_Table()
mySystem = Selection.Text
ActiveDocument.Tables(1).Rows.Add
myRows = ActiveDocument.Tables(1).Rows.Count
ActiveDocument.Tables(1).Rows(myRows).Cells(1).Select
Selection.Text = mySystem
End Sub
Of course it popluiates the first cell of the new table row with an end of line box
How can i get the name of the system (which is variable in length) into the mySystem variable ? I tried passing a variable to the subroutine
{MACROBUTTON Populate_Table(1) System 1}
{MACROBUTTON Populate_Table(2) System 2} etc
but that doesn't seem to work.