#1
|
|||
|
|||
How do I code ListBox and DatePicker in UserForm? - Word 2013
Hello,
I have prepared a proposal template for our company that contains a "Date" field and a "Projoct Cost" field. In the template, I used a date picker content control and a drop-down list content control for these fields. When I design the user form in the VBE, I don't see the option to include a date picker or drop-down list. According to Greg Maxey's user form page (http://gregmaxey.com/word_tip_pages/..._userForm.html), including these tools in the user form requires a reference to the Microsoft Forms 2.0 Object Library and Microsoft Windows Common Controls-2.6.0. I'm using Word 2013, and not able to access either through VBE Tools>References. Does anyone know of any alternate ways of coding input boxes in a user form that will allow for this functionality? Thanks, Ian |
#2
|
||||
|
||||
The drop down list doesn't require any special references but the datepicker is another matter. The Greg Maxey page you pointed us at includes the following information
"Note: Unfortunately Microsoft no longer includes the Microsoft Windows Common Control-2-6-0 (SP3) in the resource library. You need this reference for the DateAndTimePicker control to work. If you are unable to find it in the list of available resources then you will need to download MSCOMCT2.OCX (see Office Help & Support KB 297381). Once you save MSCOMCT2.OCX in your system directory (e.g., C:\Windows\System32 on 32-bit or C:\Windows\Syswow64 on 64-bit), you need to register it. Click "Start" then "Run," type in regsvr32 and then the path to the file e.g., c:\windows\syswow64\mscomct2.ocx, then click OK. If you don't want to go the trouble of doing this, I have included a second Userform in the .dot version of the Student Survey Form template that substitutes a Textbox control for birthday and omits the DateAndTimePicker control."
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thanks for the reply. If the drop-down list doesn't need any special references, then how do I code it to set the selections that appear in the drop-down on the user form? Is there a way to bind it to the content control in the document and read the drop-down selections from that document property, as the content control has already been created and the drop-down selections in the control and the user form box must match.
Thanks. |
#4
|
||||
|
||||
The primary forms elements are contained in FM20.DLL. Set a reference to Microsoft Forms 2.0 Object library.
Occasionally some users have reported FM20.DLL missing or unregistered ( in which case you will not be able to set the reference). If your PC is 64 bit (as most recent models are) then that file should be in the folder C:\Windows\SysWOW64, though it may be in C:\Windows\System32 in which case copy it to the other folder. You will then need to register it as described above (though you should register it as administrator). Date pickers are a problem as invariable the OCX file will be unregistered and it must be registered on every PC. It will not work with the 64 bit versions of Office. I would therefore recommened using a VBA picker. I personally like Trevor Eyre's version which you can download from http://bit.ly/1ossyMA
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
||||
|
||||
To populate the userform combobox with the values from a document Content Control I would try code similar to the following.
Code:
Private Sub UserForm_Initialize() Dim i As Integer With ActiveDocument.ContentControls(1).DropdownListEntries For i = 1 To .Count Me.cbTest.AddItem .Item(i).Text Next i End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word | marksm33 | Word VBA | 3 | 01-15-2015 07:55 PM |
VBA Code in a UserForm module to delete a Command Button which opens the userform | Simoninparis | Word VBA | 2 | 09-21-2014 03:50 AM |
This is a Userform LIstbox queston: A variable does not set to the value of a listbox | CatMan | Excel Programming | 14 | 08-18-2014 08:14 PM |
This is a Userform LIstbox queston: A variable does not set to the value of a listbox | CatMan | Excel | 1 | 08-08-2014 09:41 AM |
Userform Code not quite right - help please | vbanovice | Word VBA | 1 | 09-29-2013 09:20 PM |