Reputation: 83
I am attempting to find a way to use the non-activeX content controllers in Microsoft word and creating a VBA macro for them. For example a combo box. I can not for the life of me figure out how to call them in my VBA script, as every time I get a runtime error 424. I have named the combo box in its properties, but it does not seem to have the same affect as this does for the ActiveX Combo box. I must be missing something extremely easy. Any help is really appreciated. I have placed example code below;
Private Sub Document_open() 'Auto Run Macros Upon Opening of this specific doc
Call ComboBox1Additems
Call ComboBox2Additems
Call ComboBox3Additems
Call ComboBox4Additems
Call ComboBox5Additems
Call ComboBox6Additems
Call ComboBox7Additems
Call ComboBox12_Change
End Sub
Private Sub ComboBox1_Change() 'Running through possible ComboBox Values and Updating the Corrosoponding Text Box
If ComboBox1.Value = "TMS backup" Then
TextBox1.Value = "The TMS installation directory, settings directory and the database was backed up before the update was performed"
ElseIf ComboBox1.Value = "TMS installation" Then
TextBox1.Value = "Installation of version 1.17.X.19XXX performed"
ElseIf ComboBox1.Value = "TMS update" Then
TextBox1.Value = "Update from version 1.16.X.XXXXX to version 1.17.X.19XXX performed"
ElseIf ComboBox1.Value = "Tool presetter update" Then
TextBox1.Value = "Update from version 1.16.X.XXXXX to version 1.17.X.19XXX performed"
ElseIf ComboBox1.Value = "Database generated" Then
TextBox1.Value = "Database structure created with version 1.17.0"
ElseIf ComboBox1.Value = "article characteristic bar update" Then
TextBox1.Value = "Update of DIN 4000 and (CAM) structure to version 2.2.0 (DIN) and X.X.X (CAM)"
ElseIf ComboBox1.Value = "CAM-Interface installation" Then
TextBox1.Value = "Installation of the version X.X.X and configuration of the (CAM) interface"
ElseIf ComboBox1.Value = "CAM-Interface update" Then
TextBox1.Value = "Updated the (CAM) interface to version X.X.X"
ElseIf ComboBox1.Value = "WebService installation" Then
TextBox1.Value = "Installation of version 1.1.116.2 and configuration of WebService performed"
ElseIf ComboBox1.Value = "WebService update" Then
TextBox1.Value = "Update of WebService to version 1.1.116.2 performed"
ElseIf ComboBox1.Value = "CodeMeter initialized" Then
TextBox1.Value = "Set up CodeMeter on the license server and the client machines"
ElseIf ComboBox1.Value = "" Then
TextBox1.Value = "Please make a drop down selection or manually fill out if not applicable"
Else
TextBox1.Value = "Please make a drop down selection or manually fill out if not applicable"
End If
End Sub
Sub ComboBox1Additems() 'Adding Items to ActiveX Control Combo Boxes
ComboBox1.Clear
ComboBox1.AddItem "TMS backup"
ComboBox1.AddItem "TMS installation"
ComboBox1.AddItem "TMS update"
ComboBox1.AddItem "Tool presetter update"
ComboBox1.AddItem "Database generated"
ComboBox1.AddItem "article characteristic bar update"
ComboBox1.AddItem "CAM-Interface installation"
ComboBox1.AddItem "CAM-Interface update"
ComboBox1.AddItem "WebService installation"
ComboBox1.AddItem "WebService update"
ComboBox1.AddItem "CodeMeter initialized"
End Sub
Sub ComboBox12_Change()
ComboBox12.AddItem "Turkey"
ComboBox12.AddItem "Chicken"
ComboBox12.AddItem "Duck"
ComboBox12.AddItem "Goose"
ComboBox12.AddItem "Grouse"
End Sub
The ComboBox#Additems() when called run fine upon, these are pointing at activeX comboboxes. Combobox12_change() gives an error Runtime error "424", object required when run. This is "pointing" at a non-activeX combobox.
Upvotes: 0
Views: 108
Reputation: 2696
Those controls are named ContentControls
Private Sub CommandButton1_Click()
Dim ccs As ContentControls,cc as ContentControl
Set ccs= Me.ActiveWindow.Document.ContentControls
For Each cc In ccs
If cc.Title = "myTitle" Then
MsgBox cc.DropdownListEntries(1)
End If
Next
End Sub
On Document_open event those controols may not be ready.
Upvotes: 1