View Single Post
 
Old 04-14-2015, 07:17 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You created the userform correct? Then you should already know the text field names.

Code:
Private Sub CommandButton1_Click()
  'Write to three bookmarks named bmA, bmB and bmC the content of three text
  'fields txtA, txtB, txtC
  WriteToBookmark "bmA", txtA
  WriteToBookmark "bmB", txtB
  WriteToBookmark "bmC", txtC
  Unload Me
lbl_Exit:
  Exit Sub
End Sub
Sub WriteToBookmark(strBMName As String, strText As String)
Dim oRng As Word.Range
  Set oRng = ActiveDocument.Bookmarks(strBMName).Range
  oRng.Text = strText
  ActiveDocument.Bookmarks.Add strBMName, oRng
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote