Log in

View Full Version : [SOLVED:] VBA word - adding a: row to a table, label and combobox



Row
05-09-2018, 07:29 AM
Dear programmers,

I'm not a progammer, i can program a little bit bu with a lot of help and research and even then it ain pretty...
I hope you can help me with he following problem.
In the attachement is a word file with on the 3rd page an button : Add step.

The program must add an row to the table above (in this case to row 7), including a combobox and label. This needs to be in the same stye and format as the row above (7), in other words, it needs to be copied.
The caption of the label (in the new created row) is depended on the value of the combobox at the same (new) row.

So far my coding generates a new row with label and combobox only not in the same style/format as the row above. (it dumps it on te screen).

There is an classmodule made,when i run it (with the vba coder, otherwise it wouldn't work) it couples the combobox to the label.

The problem i have and what i can't figure out is placing the label and combobox at the correct coördinate's and couple them as now is done in the classmodule...

The program is for making plans with correct terminology. Row 7 is added just to show how it should look.

Many thank in advance!

With kind regards,

macropod
05-10-2018, 08:02 PM
If you save your document in the docm format and use a content control dropdown or combobox (either of which you can pre-populate) instead of the ActiveX combobox, you could use the code in either of the following for your automation - without the need for the ActiveX command button:
http://www.msofficeforums.com/word-vba/27809-code-add-new-row-table.html#post87989
http://www.msofficeforums.com/word-vba/13955-macro-add-row-table-word-form.html#post38461

Row
05-15-2018, 05:42 AM
Thanks, In the last link is a document (Table row add) that i can use.
Is it possible to show in one of the text fields the value of the dropdown menu?
And when it copies the previous row, does it also link the textbox to the dropdown menu in the same row?

Thanks in advance!

macropod
05-15-2018, 04:25 PM
There are no fields or textboxes in that implementation, so it's not apparent what you mean.

Row
05-16-2018, 04:15 AM
Sorry, sometimes in my mind i'm two steps ahead...

In the file is an sort of dropbox, in de cell next to it i want a textfield or label that shows the value of the dropbox. example: example: the user selects "measure" from the dropbox than in de label in the cell next to it, it should display: Measure voltage at:

[dropbox] [label]
Mausure measure at

Measure

macropod
05-26-2018, 11:55 PM
If you want a dropdown content control with dependent output, you might use something like the approach in:
http://www.msofficeforums.com/word-vba/16498-multiple-entries-dropdown-lists.html#post46903