nsaja.blogg.se

Vbs get activex listbox selection
Vbs get activex listbox selection











vbs get activex listbox selection

Set oRng = ActiveDocument.Bookmarks("Client").RangeĪ "Client", oRng Value property to get data from listbox bound column.Ĭlient = Client & ListBox1.Value & vbCr & vbTab Sourcedoc.Close SaveChanges:=wdDoNotSaveChanges List property to populate the listbox with the array data Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range 'Set the number of columns in the Listbox 'Get the number of list member attritbutes (i.e., table columns)

vbs get activex listbox selection

'Get the number of list members (i.e., table rows - 1 if header row is used) Set sourcedoc = Documents.Open(FileName:="D:\Data Stores\sourceWord.doc", Visible:=False) 'Modify the following line to point to your list member file and open the document

  • The code for populating the listbox and displaying the resultsįor this example, I used a source document saved as "D:\Data Stores\sourceWord.doc".
  • How the selected list item is displayed in the document.
  • How the source data is displayed in the userform.
  • Word MVP Doug Robbins has posted this method regularly in the Microsoft Word Public newsgroups.Įxample 1 - The following series of illustrations show: The first method uses a Microsoft Word table contained in a separate document as the external source. Next we will look at some methods for using an external data source to populate a listbox. Note columns are indexed _Įach of the previous examples used data contained in the userform Initialize event to create the listbox list members. 'Write userform data to bookmarked ranges in the document. List method to write array data to specific listbox row and column. AddItem method to add a multi-column row for each array element. ColumnWidth property to set column widths. & "Arkansas|California|Connecticut|Etc.", "|")ĪrrStateAbbv = Split(" |AL|AK|AZ|AR|CA|CT|Etc", "|") 'Use the Split function to create two zero based one dimensional arrays.ĪrrStateName = Split("Select State|Alabama|Alaska|Arizona|" _ A combobox can be configured to accept pre-defined list entries only or allow the user to enter his or her own text. You can download the demonstration document containing all of the example userforms and VBA procedures used to prepare this tips page with the link at the end of the page.Ī listbox provides users with a convenient means of selecting one or more items from a fixed pre-defined list.Ī combobox provides users with a compact and convenient means of selecting a single item from a pre-defined list. For brevity, I will use one term or the other in the examples that follow.ģ. The basic process for populating a listbox or combobox is the same. See my Create & Employ a Userform tips page for information on creating and employing userforms.Ģ.

    vbs get activex listbox selection

    Microsoft Word MVP Doug Robbins has kindly assisted with the preparation of this page. This Microsoft Word Tips & Microsoft Word Help page demonstrates several methods that you can use to populate a userform listbox (or combobox).













    Vbs get activex listbox selection