none
WdFieldType.wdFieldFormDropDown - TextWrap RRS feed

  • Question

  • I'm adding a text drop down box in the middle of a paragraph, using the following code:

      InputText = Globals.ThisDocument.FormFields _
                 .Add(Range:=TextRange, Type:=WdFieldType.wdFieldFormDropDown)
    
                InputText.DropDown.ListEntries.Add("will be continued as previously instructed.")
                InputText.DropDown.ListEntries.Add("have stopped as a result of this transaction.")

    The issue I'm having is trying to get the drop down box to text wrap.  Since the text in the drop down box is several words long, it moves the entire Drop Down box to a new line, which makes the paragraph look rather sloppy.

    So, is there a way to have the Drop Down Box wrap text to split across two lines?

    Wednesday, December 12, 2012 5:14 PM

Answers

  • No, I'm afraid not.

    The standard "workaround" for dropdown form fields that don't provide all the desired functionality is to use a textbox formfield instead with an "On Enter" macro. This displays a VBA user form that provides the list of items. When the user has selected what he wants an "OKs" the information is written to the textbox. The textbox formfield will wrap.

    Of course, the described approach won't work in a VSTO solution since it's not possible to link a form field to VSTO code (or you'd have include VBA in the VSTO document).

    If this is Office 2007 or later you could use a ContentControl instead as that does link to VSTO code.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 13, 2012 6:45 AM
    Moderator

All replies

  • No, I'm afraid not.

    The standard "workaround" for dropdown form fields that don't provide all the desired functionality is to use a textbox formfield instead with an "On Enter" macro. This displays a VBA user form that provides the list of items. When the user has selected what he wants an "OKs" the information is written to the textbox. The textbox formfield will wrap.

    Of course, the described approach won't work in a VSTO solution since it's not possible to link a form field to VSTO code (or you'd have include VBA in the VSTO document).

    If this is Office 2007 or later you could use a ContentControl instead as that does link to VSTO code.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 13, 2012 6:45 AM
    Moderator
  • Thanks Cindy, that's what I was figuring the answer was going to be, I just wanted to confirm.

    I'm using office 2010, so the work around might be the answer. 

    I've been trying to mark your answer but I keep getting an error, I might have to try later.

    Thursday, December 13, 2012 2:02 PM
  • <<I've been trying to mark your answer but I keep getting an error>>

    Looks like it "took", although it doesn't mention who marked it, so something in the system wasn't quite right...


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 13, 2012 2:13 PM
    Moderator