Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Aug 2013
    Posts
    46
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Dropdown menu: Can a default value be set?

    I use such a code to create drop down list:

    Code:
    Set DRP_obj = Selection.Range.ContentControls.Add(wdContentControlDropdownList)
     With DRP_obj.DropdownListEntries
            .Add p1
            .Add p2
            .Add p3
     End With
    Can a certain value (e.g. P1) appear as selected instead the "choose an item"?
    Can I modify the "choose an item" with my own text, such as "Chose a day"?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    You can modify the placeholder text and/or select an item as the default. For example:
    Code:
    Sub Test()
    Dim DRP_obj As ContentControl
    Set DRP_obj = Selection.Range.ContentControls.Add(wdContentControlDropdownList)
    With DRP_obj
      .SetPlaceholderText , , "Choose a day"
      With .DropdownListEntries
        .Add "p1"
        .Add "p2"
        .Add "p3"
      End With
      .DropdownListEntries(1).Select
    End With
    End Sub
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. The Following User Says Thank You to macropod For This Useful Post:

    YigalB (2014-11-06)

  5. #4
    Lounger
    Join Date
    Aug 2013
    Posts
    46
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    You can modify the placeholder text and/or select an item as the default. For example:
    Code:
    Sub Test()
    Dim DRP_obj As ContentControl
    Set DRP_obj = Selection.Range.ContentControls.Add(wdContentControlDropdownList)
    With DRP_obj
      .SetPlaceholderText , , "Choose a day"
      With .DropdownListEntries
        .Add "p1"
        .Add "p2"
        .Add "p3"
      End With
      .DropdownListEntries(1).Select
    End With
    End Sub
    Thanks. Working great.

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
  •