Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-11-2016, 04:03 PM
ptmuldoon ptmuldoon is offline UserForm of Autotext Entries Windows 7 64bit UserForm of Autotext Entries Office 2013
Advanced Beginner
UserForm of Autotext Entries
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default

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
Currently, when I attempt to change between AR Ineligible and Inv Ineligible, I get an error message with the Case 1 of the on change event here?

Code:
 Me.ComboBox2.Column(1, i - 1) = oBuildingBlock.Value
Again, it is that line in Case 1, and not Case 0

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?
Reply With Quote
 

Thread Tools
Display Modes


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
UserForm of Autotext Entries 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:40 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft