![]() |
|
#2
|
|||
|
|||
|
I think I've made some considerable progress, but am currently getting an error when I attempt to change between the selections:
This is the entire userform, which has an 2 comboboxes, 1 text box and command button. And the autotext is being store in the 'ReportMacros' file that is loaded at the Word Startup Code:
Option Explicit
Private Sub CommandButton1_Click()
Selection.TypeText ComboBox2.Value
'Unload Me
End Sub
Private Sub ComboBox1_Change()
Dim index As Integer
Dim objTemplate As Template
Dim oBuildingBlock As BuildingBlock
Dim i As Integer
Dim sPath As String
' Set the template to store the building block
sPath = Environ("APPDATA") & "\Microsoft\Word\STARTUP\ReportMacros.dotm"
Set objTemplate = Templates(sPath)
index = ComboBox1.ListIndex
ComboBox2.Clear
Select Case index
Case Is = 0 'AR Ineligibles
For i = 1 To objTemplate.BuildingBlockEntries.Count
Set oBuildingBlock = objTemplate.BuildingBlockEntries.Item(i)
If oBuildingBlock.Type.Name = "Custom AutoText" And oBuildingBlock.Category.Name = "AR Ineligibles" Then
Me.ComboBox2.AddItem oBuildingBlock.Name
Me.ComboBox2.Column(1, i - 1) = oBuildingBlock.Value
End If
Next i
Me.ComboBox2.Text = Me.ComboBox2.List(0)
Case Is = 1 'Inventory Ineligibles
For i = 1 To objTemplate.BuildingBlockEntries.Count
Set oBuildingBlock = objTemplate.BuildingBlockEntries.Item(i)
If oBuildingBlock.Type.Name = "Custom AutoText" And oBuildingBlock.Category.Name = "Inv Ineligibles" Then
Me.ComboBox2.AddItem oBuildingBlock.Name
Me.ComboBox2.Column(1, i - 1) = oBuildingBlock.Value
End If
Next i
Me.ComboBox2.Text = Me.ComboBox2.List(0)
End Select
End Sub
Private Sub ComboBox2_Change()
TextBox1.Value = ComboBox2.Value
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "AR Ineligibles"
.AddItem "Inv Ineligibles"
End With
Me.ComboBox1.Text = Me.ComboBox1.List(0)
End Sub
Code:
Me.ComboBox2.Column(1, i - 1) = oBuildingBlock.Value The error Message is Run Time Error '381' Could not set the column property Invalid Property Array Index Can anyone help with that error code? |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Userform calls other userform, then populate worksheet | Lehoi | Excel Programming | 0 | 02-03-2016 02:58 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 |
Is it possible to take an input from a UserForm in one document to a UserForm in a do
|
BoringDavid | Word VBA | 5 | 05-09-2014 09:08 AM |
| Using Word autocorrect and autotext entries in outlook | dswapp | Outlook | 2 | 11-24-2010 10:18 AM |
| Maintaining AUtotext Entries from an external table. | kelzud | Word Tables | 0 | 07-28-2009 01:31 PM |