S
Shauna Koppang
This is a continuation from my previous message with added
information.
I am a rank beginner with VBA and this is my firt attempt
at a UserForm. I need to eventually create a dialog box
that users can either check, type in or pick from a list,
selected items to complete a template. So I am
experimenting with now creating a Userform with each of
the items on it. Here is the code so far. After I will
explain where I am still having troubles:
Private Sub UserForm_Initialize()
'Handling ListBox list
ListBox1.List = Array("By Mail", "By Mail & Fax", "By
Mail & E-mail", "By Fax & E-mail", "By Hand", "By
Courier", "By Special Delivery", "By Registered Mail")
ListBox1.ListIndex = 0
'Sensitivity ComboBox list
ComboBox1.AddItem "Personal"
ComboBox1.AddItem "Private"
ComboBox1.AddItem "Confidential"
ComboBox1.AddItem "Personal & Confidential"
ComboBox1.AddItem "Private & Confidential"
'Use drop-down list
ComboBox1.Style = fmStyleDropDownList
'Combo box values are ListIndex values
ComboBox1.BoundColumn = 0
'Set combo box to first entry
ComboBox1.ListIndex = 0
End Sub
Private Sub CommandButton1_Click()
'Handling List Box
If ListBox1.ListIndex >= 0 Then
With ActiveDocument
.Bookmarks("Text1").Range.InsertBefore
ListBox1.Text
End With
Else
MsgBox "You must select an item."
End If
'Sensitivity ComboBox
If ComboBox1.ListIndex >= 0 Then
With ActiveDocument
.Bookmarks("Text2").Range.InsertBefore
ComboBox1.Text
End With
Else
MsgBox "You must select or type an item."
End If
'Text Box
With ActiveDocument
.Bookmarks("Text3").Range.InsertBefore TextBox1
'If Len(.Result) = 0 Then
' MsgBox "You must fill in this field"
'End If
End With
UserForm1.Hide
End Sub
Help with:
The ComboBox works to pick items from it and it places the
selecting into the bookmark, however, I cannot figure out
how to get it so I can type in it then get the result to
be placed at that bookmark.
The TextBox will appear and I can type in and it will
place the result into the bookmark, however, the code (now
commented out) for an error message if not filled in, does
not seem to work.
Have not tried a check box yet or radio button! That's
next. Yikes.
I appreciate your patience with this and your assistance.
Shauna
information.
I am a rank beginner with VBA and this is my firt attempt
at a UserForm. I need to eventually create a dialog box
that users can either check, type in or pick from a list,
selected items to complete a template. So I am
experimenting with now creating a Userform with each of
the items on it. Here is the code so far. After I will
explain where I am still having troubles:
Private Sub UserForm_Initialize()
'Handling ListBox list
ListBox1.List = Array("By Mail", "By Mail & Fax", "By
Mail & E-mail", "By Fax & E-mail", "By Hand", "By
Courier", "By Special Delivery", "By Registered Mail")
ListBox1.ListIndex = 0
'Sensitivity ComboBox list
ComboBox1.AddItem "Personal"
ComboBox1.AddItem "Private"
ComboBox1.AddItem "Confidential"
ComboBox1.AddItem "Personal & Confidential"
ComboBox1.AddItem "Private & Confidential"
'Use drop-down list
ComboBox1.Style = fmStyleDropDownList
'Combo box values are ListIndex values
ComboBox1.BoundColumn = 0
'Set combo box to first entry
ComboBox1.ListIndex = 0
End Sub
Private Sub CommandButton1_Click()
'Handling List Box
If ListBox1.ListIndex >= 0 Then
With ActiveDocument
.Bookmarks("Text1").Range.InsertBefore
ListBox1.Text
End With
Else
MsgBox "You must select an item."
End If
'Sensitivity ComboBox
If ComboBox1.ListIndex >= 0 Then
With ActiveDocument
.Bookmarks("Text2").Range.InsertBefore
ComboBox1.Text
End With
Else
MsgBox "You must select or type an item."
End If
'Text Box
With ActiveDocument
.Bookmarks("Text3").Range.InsertBefore TextBox1
'If Len(.Result) = 0 Then
' MsgBox "You must fill in this field"
'End If
End With
UserForm1.Hide
End Sub
Help with:
The ComboBox works to pick items from it and it places the
selecting into the bookmark, however, I cannot figure out
how to get it so I can type in it then get the result to
be placed at that bookmark.
The TextBox will appear and I can type in and it will
place the result into the bookmark, however, the code (now
commented out) for an error message if not filled in, does
not seem to work.
Have not tried a check box yet or radio button! That's
next. Yikes.
I appreciate your patience with this and your assistance.
Shauna