Check Box or Radio button that adds text to a bookmark

R

robandcurtis

Below is the UserForm I have created for doing a repetative task at
work. It has served us very well, however I would like to knwo how to
add an option that is either a Radio Button or a Checkbox that, if
selected, will insert some predefined text into a bookmark, and if not
selected insert nothing. I have read everything I can find on the
subject on the pages that I used to create this, but cannot find an
answer that works. Thanks!

--snip--


Private Sub UserForm_Initialize()

With Me.ComboBox1
.AddItem "Select your signature"
.AddItem "Rob Jesson" & vbCr & "Support Consultant" & vbCr & "Admin
Team" & vbCr & "Information Management"
.AddItem "James Lefave" & vbCr & "Support Consultant" & vbCr &
"Admin Team" & vbCr & "Information Management"
.AddItem "Dan Craig" & vbCr & "Support Consultant" & vbCr & "Admin
Team" & vbCr & "Information Management"
.AddItem "Greg Martin" & vbCr & "Support Consultant" & vbCr &
"Admin Team" & vbCr & "Information Management"
.AddItem "Jason Kimmerly" & vbCr & "Support Consultant" & vbCr &
"Admin Team" & vbCr & "Information Management"
.AddItem "Jacqui Lines" & vbCr & "Second Level Support Specialist"
& vbCr & "Admin Team" & vbCr & "Information Management"
.ListIndex = 0
End With

With Me.ComboBox2
.AddItem "Add WLM Request Notification Sent"
.AddItem "***Note: A request for Infomed Access has been forwarded
to Workload Measuerment."
.AddItem "***Note: A request for WinPfs Access has been forwarded
to Workload Measuerment."
.AddItem "***Note: A request for GRASP Access has been forwarded to
Workload Measuerment."
.AddItem "***Note: A request for TREAT Access has been forwarded to
Workload Measuerment."
.ListIndex = -1
End With

With Me.ComboBox3
.AddItem "Add S:Drive Request Notification Sent"
.AddItem "***Note: A request for S: Drive access has been forwarded
to the Folder Owners for:"
.ListIndex = -1
End With


End Sub



Private Sub CommandButton1_Click()
With Me.ComboBox1
If .ListIndex = 0 Then
MsgBox "You must select a signature."
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
Exit Sub
Else
ActiveDocument.Bookmarks("SigPlace").Range _
.InsertAfter .Text
End If
End With
With Me.ComboBox2
ActiveDocument.Bookmarks("WLM").Range _
.InsertAfter .Text
End With

With Me.ComboBox3
ActiveDocument.Bookmarks("SDRIVE").Range _
.InsertAfter .Text
End With

With ActiveDocument
.Bookmarks("FirstName").Range _
.InsertBefore TextBox1
.Bookmarks("LastName").Range _
.InsertBefore TextBox2
.Bookmarks("LoginID").Range _
.InsertBefore TextBox3
.Bookmarks("GWLogin").Range _
.InsertBefore TextBox3
.Bookmarks("Password").Range _
.InsertBefore TextBox4
.Bookmarks("GWPass").Range _
.InsertBefore TextBox4
.Bookmarks("Context").Range _
.InsertBefore TextBox5
.Bookmarks("CLID_ID").Range _
.InsertBefore TextBox3
.Bookmarks("CLID_CONT").Range _
.InsertBefore TextBox5
.Bookmarks("Department").Range _
.InsertBefore TextBox6
.Bookmarks("PO").Range _
.InsertBefore TextBox7
.Bookmarks("GW_GROUPS").Range _
.InsertBefore TextBox8
.Bookmarks("SMTP_FN").Range _
.InsertBefore TextBox1
.Bookmarks("SMTP_LN").Range _
.InsertBefore TextBox2
.Bookmarks("GWWA").Range _
.InsertBefore TextBox3
.Bookmarks("GWAA_PASS").Range _
.InsertBefore TextBox4
.Bookmarks("DESKTOP_ID").Range _
.InsertBefore TextBox3
.Bookmarks("ADD_DIR").Range _
.InsertBefore TextBox10
.Bookmarks("LINX_ID").Range _
.InsertBefore TextBox3
.Bookmarks("LINX_PASS").Range _
.InsertBefore TextBox3
.Bookmarks("LINX_Position").Range _
.InsertBefore TextBox11
.Bookmarks("EMP_ID").Range _
.InsertBefore TextBox12
.Bookmarks("DOB").Range _
.InsertBefore TextBox13
.Bookmarks("S1").Range _
.InsertBefore TextBox14
.Bookmarks("SUB_LN").Range _
.InsertBefore TextBox2
.Bookmarks("SUB_FN").Range _
.InsertBefore TextBox1
.Bookmarks("SUB_CN").Range _
.InsertBefore TextBox4
Selection.WholeStory
Selection.Copy
Application.Quit SaveChanges:=wdDoNotSaveChanges


End With



End Sub






Private Sub CommandButton2_Click()
Application.Quit SaveChanges:=wdDoNotSaveChanges

End Sub


Private Sub UserForm_Click()

End Sub


--snip--
 
G

Greg Maxey

Something like this should do:

Private Sub CheckBox1_Click()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("myBookmark").Range
If Me.CheckBox1.Value = True Then
oRng.Text = "Some predefined text"
ActiveDocument.Bookmarks.Add "myBookmark", oRng
Else
oRng.Text = ""
ActiveDocument.Bookmarks.Add "myBookmark", oRng
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top