View Single Post
 
Old 01-24-2019, 10:01 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Another way is to use the following macro to write your values to the bookmarks
You can then call it from your form e.g.
Code:
FillBM "bmDate", txtDate.Value
FillBM "bmName", txtName.Value
This ensures that the text is written IN the bookmark rather than AT it, thus enabling the values to be recalled to the userform should you wish to recall the userform to edit the document.
For optional insertions
Code:
If chckIEP.Value = True Then
    FillBM "bmIEP", "Request IEP"
Else
    FillBM "bmIEP", ""
End If
Code:
Public Sub FillBM(strbmName As String, strValue As String)
'Graham Mayor - http://www.gmayor.com
Dim orng As Range
    With ActiveDocument
        On Error GoTo lbl_Exit
        Set orng = .Bookmarks(strbmName).Range
        orng.Text = strValue
        orng.Bookmarks.Add strbmName
    End With
lbl_Exit:
    Set orng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote