Multi Layer DropDown Boxes Word 2010

Posted on 2011-05-07
Medium Priority
Last Modified: 2012-05-11
Hi Experts,

I use Word sparingly so have no idea on VB code etc so you'll have to be gentle with me if the following is simple (or walk me through very carefully if its difficult!)

I'm working on a word document that will provide a proposal to clients. One of the sections has to do with their SLA. I'd like to have a dropdown that allows me to choose the SLA level (Bronze,silver, gold , platinum) which is fairly easy BUT

Based upon that selection I then want to be able to add lines to a table (sometimes only two or 3 lines, sometimes more like 10 or 12 - each will be different so I need the table to grow as required but ideally not have to then remove blank lines) but the possible additions will be determined by the SLA chosen.

I then want to automatically add a price on the end based on the previous two so it would look something like:

Gold               Wigdet Support                         $200
Silver              Sprocket Support                      $150

etc etc

I may be trying to be too clever (maybe I just have to have one SLA that then sets up the table so if I choose gold at the top then all support is gold and priced as such?)

No coding skills at all but willing to try so any pointers happily taken


Question by:Randy_Bojangles
  • 3
  • 3
LVL 76

Expert Comment

ID: 35713001
Not sure what sort of dropdown you are using, but it all sounds quite possible.

Here is some code to add and fill a couple of rows to the first table in the current document.
Sub AddRows()
    Dim tbl As Table
    Dim i As Integer
    Dim rw As Row
    Set tbl = ActiveDocument.Tables(1)
    Set rw = tbl.Rows.Add
    rw.Cells(1).Range.Text = "Gold"
    rw.Cells(2).Range.Text = "Wigdet Support"
    rw.Cells(3).Range.Text = "$200"
    Set rw = tbl.Rows.Add
    rw.Cells(1).Range.Text = "Silver"
    rw.Cells(2).Range.Text = "Sprocket Support"
    rw.Cells(3).Range.Text = "$150"
End Sub

Open in new window

LVL 13

Author Comment

ID: 35713221
so I think I see what this does in terms of drawing the the table - thanks

However when I run it it says Cant execute in break mode?

Also this seems to be that I have to define the objects in the macro (Gold, Widget Support etc)

What I want is to be able to pick each of those things from a dropdown as it will be different each time (I think I'm explaining this poorly)

So next customer may not have widget support and may have bronze on sprockets etc and I want to be able to build it up for each customer s I go

If this is way too much work then I'll have to do it by hand I guess

Thanks for your help so far though!
LVL 76

Expert Comment

ID: 35713267
There can be only one set of VBA code running per instance of an application. If some code has entered break mode for any reason e.g. error, user pressed Ctrl+break, code hit a breakpoint etc, another (or even the same) set of VBA code cannot be started. That is what the message means. In the VBA window, you should see the word in the title caption, and some code highlighted in yellow.

Whatever the programming environment, we have to be clear about our requirements and datasources.

Also, it is not clear about where the dropdown is. If you have a complex selection process that does not need to appear on the document, then, I suggest, it would be best to use VBA UserForms to gather the data and to, if necessary, present further means of selecting details, depending on earlier selections.

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

LVL 13

Author Comment

ID: 35716115
I can have all of the possible options (they are finite, though complex) held elsewhere - they're currently in an Excel sheet

I have no idea what a VBA userForm is though!
LVL 76

Accepted Solution

GrahamSkan earned 2000 total points
ID: 35716552
Most VBA-enabled applications - Access is a notable exception - can create a form that is not part of the document. By document I mean the presentation object that the application is intended for - in Word it is formally a Document, but it could be a Spreadsheet (Excel), a Message (Outlook) or a Slide (Powerpoint).

In Word, VBA (and its UserForms) are aids to producing a final document, ready for printing.

To complete your task, I think that you would need to learn at least an overview of VBA and to post extra questions if and when you get stuck again. However, your question is beginning to look rather larger than what is generally thought of as a single question. In fact it's beginning to resemble a project.

An alternative would be to turn it over to a professional VBA programmer, such as you might find via something like Rent-a-coder. But also note that some of the experts here will take on paid projects. If so, the fact and contact information will be in their profile.
LVL 13

Author Comment

ID: 35718693
Ok then, thanks

If you could point me in the direction of some good starting documentation/web articles etc then that would be appreciated

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question