View Single Post
 
Old 05-24-2017, 08:26 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
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

I would recommend that you use the function FillBM from my web site (and repeated below) to fill the named bookmark (of which the spelling must be correct). The syntax here would be

FillBM "BorrowerName", txtBorrowerName.Text

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
In a simple userform the code could be like the following, albeit with your bookmark names and the textbox texts.

Code:
Private Sub cmdOK_Click()
   'Hide the userform
   Hide
   'e.g. Assign the values of the three text boxes to the three   bookmarks
   'Using the Function FillBM
   FillBM "bm1", TextBox1.Text
   FillBM "bm2", TextBox2.Text
   FillBM "bm3", TextBox3.Text
   'Unload the form
   Unload Me
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