How to reference in VBA an HTML Select control in a Word document
Posted on 2010-09-03
I have been supplied with a Word 2003 document that has a number of HTML Select drop down lists within it. This document will be used by a process within Access 2007 to merge data, creating a Word 2003 document within Word 2007 using DOCPROPERTY fields.
I would like to be able to set the values within the HTML Select controls using VBA within the Access merge process that I have created. This process uses the Word object model and the required document that is acting as the template (in the English sense of the word, not a .dot file)
The supplied document is owned by an organisation that wishes to keep control over the document structure and layout so I have been trying to reference the HTML Select controls from within VBA in order to set the required value.
Other options already investigated include:
1. Replacing the HTML Select control with a DOCPROPERTY, but this removes the ability to manually adjust the data
2. Replacing the control with a combo box in Word but this will probably not be acceptable to the owner of the original document
3. Searching here and generally for a solution
I've tried setting a reference to the Microsoft HTML Object Library and the Microsoft Forms 2.0 Object Library but seem to be going round in circles trying to reference the controls from within VBA.
I've been playing around in the Word VBA window with the document open and can loop through the controls as Fields within the ActiveDocument Fields collection but this doesn't allow me to see the HTMLSelect control properties such as Name and DisplayValues.
I'm probably missing something obvious here but I'm going round in circles trying to solve this one now.
Thanks in advance.