Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating ComboBox in Word 2007

Status
Not open for further replies.

bubba100

Technical User
Nov 16, 2001
493
US
There is a Word template that we use that was developed over the last 4 years. It is protected as there are only certain items that need to be added for that particular customer. It gets printed then never saved. It was designed in Word 2003 and has been included on machines that use Word (Office) 2007. Until this week it worked in Word 07 in the compatibility mode (we continued to use the dot file extension).
Starting this week the machines with Word 2007 show a message when we try and create a new document from the template “Can’t exit design because Control Combobox1 can’t be created”. I have tried this template on several machines with the same results. I keep a backup machine (with Word 2007) that is used to test that hasn’t been used for the past month. The template worked. Our IT pushes Windows and Office updates to our machines and this one didn’t have them YET. After they were installed guess what same problem as the others.
Looks like update KB2251419 and or KB2277947 (the first being a Word07 and the second being Office07) are at the root.

What we have is a template that contains a ComboBox that is used to select a name that will then add the mailing address. I use some code in the Document_New and Document_Open that inserts these names.

ActiveDocument.FormFields("txtbxDate").Result = Date
ComboBoxSuper.List = Array("FAS", "Meme ", "Mike ", "Karen ", _
"Steve ", "Joe ")

I have tried using the ComboBoxSuper.AddItem and still receive the same message.

This still works in Word 2003. But we are slowly moving to Office 2007.

Has anyone run into YET ? If so any ideas are appreciated.

Thanks for taking a look.

 
I have had a similar problem (not with office 2007) that adding MSForms.CombBox...etc fixed.
 
Could you give a more detailed explaination?
 
I think we need more details.

ActiveDocument.FormFields("txtbxDate").Result = Date
ComboBoxSuper.List = Array("FAS", "Meme ", "Mike ", "Karen ", _
"Steve ", "Joe ")

What is the connection between the FormField, and the ComboBox? There is no connection AFAIK.

I think you need to post the full _Open and/or _New code.

Gerry
 
Actually the txtbxDate is used only to add the current date when a new document is created from the template. The only thing I have “changed” are the names—to protect the innocent.



Private Sub Document_New()
ActiveDocument.FormFields("txtbxDate").Result = Date
ComboBoxSuper.List = Array("FAS", "Meme", "Mike", "Karen")
End Sub

Private Sub Document_Open()
'ActiveDocument.FormFields("txtbxDate").Result = Date
ComboBoxSuper.List = Array("FAS", "Meme", "Mike", "Karen")
End Sub
 
OK. I made a document, and I put in controls using the same names (I even added the formfield.):
Code:
Sub Document_Open()
ActiveDocument.FormFields("txtbxDate").Result = Date
ComboBoxSuper.List = Array("FAS", "Meme", "Mike", "Gerry")
End Sub
It works perfectly.


Mind you I used legacy controls in 2007. So ComboBoxSuper is NOT a ContentControl.

Gerry
 
This DID work in Word 2007 until updates KB2251419 and KB2277947 from Microsoft. I will begin again on Monday.

Thanks.
 
I can not help you with anything more. if this is an effect of Microsoft "fixing" things...what can I say?

Other than "remote code execution" vulnerability has been an issue for 10 years with Microsoft products and I predict no end in sight.

Gerry
 
The Problem I had was that on some machines the library needed to be included as well as the class. So
"combobox.additem" caused an error but
"MSForms.combobox.additem" was OK.
 
Gerry- You have helped many times in the past, even if you didn't know as I try and ask to assistance AFTER researching. Your name comes up often. Thanks.

NNett- As there is more than 1 combobox there is more than one way to "skin a cat". I'll give it a go. Thanks.
 
combobox.additem" caused an error but"MSForms.combobox.additem" was OK. "

Actually, this is a case for always using fully qualified instructions. Normally, if the code is in the ThisDocument module, then combobox_X.AddItem should work. Now, why those "fixes" are messing things up...who knows. They are clearly legacy objects, and yes indeed ActiveX objects do run code. Which is why Highsecurity disables them.

Gerry
 
They are clearly legacy objects, and yes indeed ActiveX objects do run code." Correct, I tried the various Comboboxes from Word 2003 and the legacy Combobox in Word 2007 with the same results.
The original template still works on machines with Word 2003.

So the "fix" for me was to convert the template from a DOT to DOTM delete the offending combobox and insert the Combobox Content Control (Word 2007). It allows me to add the names needed without using code. There are different Events for Content Controls to learn.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top