View Single Post
 
Old 01-24-2019, 09:42 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Actually your checkboxes are named chckIEP and chckPsy

I would address this by adding the bookmark name and text values to the tag and ControlTipText properties on the relevant userform checkboxes. Then you implement the following code changes to the userform code - amend OK_Click and add the PopulateBM function.
Code:
Private Sub OK_Click()
  Application.ScreenUpdating = False
  With ActiveDocument
     .Bookmarks("bmDate").Range.Text = txtDate.Value
     .Bookmarks("bmName").Range.Text = txtName.Value
     .Bookmarks("bmUCI").Range.Text = txtUCI.Value
     .Bookmarks("bmDOB").Range.Text = txtDOB.Value
     .Bookmarks("bmSchool").Range.Text = txtSchool.Value
     .Bookmarks("bmIEPY").Range.Text = txtIEPY.Value
     .Bookmarks("bmPsyY").Range.Text = txtPsyY.Value
     .Bookmarks("bmSC").Range.Text = txtSC.Value
    PopulateBM Me.chckIEP
    PopulateBM Me.chckPsy
  End With
  Application.ScreenUpdating = True
  Unload Me
End Sub

Function PopulateBM(aCtl As Control)
  Dim sBkmk As String, sText As String
  sBkmk = aCtl.Tag
  sText = aCtl.ControlTipText
  With ActiveDocument
    If .Bookmarks.Exists(sBkmk) Then
      If aCtl Then
        .Bookmarks(sBkmk).Range.Text = sText
      Else
        .Bookmarks(sBkmk).Range.Text = ""
      End If
    End If
  End With
End Function
Attached Images
File Type: png TagIt.png (20.7 KB, 40 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote