Multi Layer DropDown Boxes Word 2010

Posted on 2011-05-07
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
    LVL 76

    Expert Comment

    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

    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

    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.

    LVL 13

    Author Comment

    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

    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

    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

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range propeā€¦
    Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
    The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now