View Single Post
 
Old 01-20-2015, 04:10 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

Call the following sub to fill your bookmarks with the data required. You can call it from your userform e.g. as follows, replacing the bookmark names and values as appropriate.

Code:
Select Case Me.ComboBoxName.ListIndex
        Case 0
               FillBM "Bookmarkname", "Value to put in bookmark"
               FillBM "AnotherBookmarkname", "Another value to put in bookmark"
         'etc
     Case 1
               FillBM "Bookmarkname", "Value to put in bookmark"
               FillBM "AnotherBookmarkname", "Another value to put in bookmark"
         'etc
     'Repeat for each list index as required
End Select
Code:
Public Sub FillBM(strBMName As String, strValue As String)
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:
    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