Consulting

Results 1 to 3 of 3

Thread: Use Drop-Down List Content Control to Populate Bookmark (multiselect)

  1. #1
    VBAX Newbie
    Joined
    Dec 2022
    Posts
    1
    Location

    Use Drop-Down List Content Control to Populate Bookmark (multiselect)

    Hello,

    I have programmed in VBA for years but mostly in Excel. Right now, I am making a .DOTX or template file in Word and I have a Drop-Down List (content control style) and I am attempting to give users the ability to select items from the list and have the selections populate to preselected locations in the Word Document. Does that make sense?

    My main issue is that I have no working knowledge of the vba behind these "content controls" I just spent hours reading through literature about them but can't quite wrap my head around it. Below is my really bad attempt at what I am trying but should shed some light on where I am going with this. Basically, I would like the user to "activate" the drop down, click the item them want, and it will populate directly below (using a bookmark) in the word document. If they select another item, it will in some way populate with the first item or move on to the next line below the first entry.

    I know this is not great but I think it will guide a better understanding of what I am trying to accomplish. Hopefully it is possible and thanks in advance.

    Sub DDmulti()
    Dim doc As Word.Document
        Dim ccLB As Word.ContentControl
        Set doc = ActiveDocument
        Set ccLB = doc.SelectContentControlsByTitle("lb").Item(1)
    If ccLB.selected Then
     Selection.GoTo What:=wdGoToBookmark, Name:="lb"
      With Selection
     Selection.Add
     End With
    End If
    End Sub
    Last edited by Aussiebear; 12-02-2022 at 01:41 PM. Reason: Added code tags to supplied code

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    The code you've posted isn't anything like what one would use for populating a document from a dropdown content control selection. See, for example: [SOLVED] Dependent Drop Down Lists in Word (vbaexpress.com), where there is code that does much more than what you're asking.

    See also:

    Dependent Text Content Controls
    https://www.msofficeforums.com/word-...html#post46903
    and, for different elements from a selected item to be output to different content controls:
    https://www.msofficeforums.com/word-...tml#post120392


    Dependent Dropdown Content Controls
    https://www.msofficeforums.com/word-...html#post77762
    and, for multiple levels of dependency:
    https://www.msofficeforums.com/word-...tml#post132696


    Cascading Dropdown Content Controls
    https://www.msofficeforums.com/word-...html#post94603


    Content Control Conditional Formatting
    https://www.msofficeforums.com/word-...html#post47254


    Dropdown Content Control Population from Excel
    https://www.msofficeforums.com/word-...html#post46287

    Creating and Tallying Mutually-exclusive Checkboxes
    https://www.msofficeforums.com/word-...html#post33489
    https://www.msofficeforums.com/word-...tml#post107008


    Adding a New Row to a Table:
    https://www.msofficeforums.com/word-...html#post87989
    https://www.msofficeforums.com/word-...html#post38461
    https://www.msofficeforums.com/word-...tml#post145675

    I note that your post title refers to 'multiselect'. Neither dropdown nor combobox content controls allow more than one item to be selected at a time.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Instead of a vba solution, consider simply using a mapped content control. The choice will be reflected in each copy of the control.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •