A
Anne P.
Hi,
I have the following code in UserForm_Initialize to fill several combo boxes
with AutoText entries. I want to set a certain entry to be the default
after the items are loaded, but I can't seem to figure out how to set the
ListIndex. Short of hard coding, how do I set it to say the 4th entry in
the list? Or should I just set it based on the text that I want to appear
as the default?
Private Sub UserForm_Initialize()
'Fill the combo boxes for Greetings, Closings, Delivery and Enclosures
Dim objAtE As AutoTextEntry
Dim objTemplate As Template
'Loop through all the templates until you find the correct one
'When you do store it as objTemplate
For Each objTemplate In Templates
If objTemplate.Name = "SKGlobal.dot" Then
Exit For
End If
Next objTemplate
For Each objAtE In objTemplate.AutoTextEntries
If objAtE.StyleName = "Closing" Then
cmbClosing.AddItem objAtE.Name
End If
If objAtE.StyleName = "Salutation" Then
cmbGreeting.AddItem objAtE.Name
ListIndex = 1
End If
If objAtE.StyleName = "Mailing Instructions" Then
cmbDelivery.AddItem objAtE.Name
End If
If objAtE.StyleName = "Special Instructions" Then
cmbEnclosure.AddItem objAtE.Name
End If
Next objAtE
End Sub
Thanks in advance for any suggestions.
Anne P.
I have the following code in UserForm_Initialize to fill several combo boxes
with AutoText entries. I want to set a certain entry to be the default
after the items are loaded, but I can't seem to figure out how to set the
ListIndex. Short of hard coding, how do I set it to say the 4th entry in
the list? Or should I just set it based on the text that I want to appear
as the default?
Private Sub UserForm_Initialize()
'Fill the combo boxes for Greetings, Closings, Delivery and Enclosures
Dim objAtE As AutoTextEntry
Dim objTemplate As Template
'Loop through all the templates until you find the correct one
'When you do store it as objTemplate
For Each objTemplate In Templates
If objTemplate.Name = "SKGlobal.dot" Then
Exit For
End If
Next objTemplate
For Each objAtE In objTemplate.AutoTextEntries
If objAtE.StyleName = "Closing" Then
cmbClosing.AddItem objAtE.Name
End If
If objAtE.StyleName = "Salutation" Then
cmbGreeting.AddItem objAtE.Name
ListIndex = 1
End If
If objAtE.StyleName = "Mailing Instructions" Then
cmbDelivery.AddItem objAtE.Name
End If
If objAtE.StyleName = "Special Instructions" Then
cmbEnclosure.AddItem objAtE.Name
End If
Next objAtE
End Sub
Thanks in advance for any suggestions.
Anne P.