Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-20-2015, 07:15 AM
gmaxey gmaxey is offline Linking Combobox to multiple bookmarks Windows 7 32bit Linking Combobox to multiple bookmarks Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Graham has shown you one way. I'm going to Shanghai part of his code to show you another. If you define all of your variables in the combobox (multi-column) you can do it like this:

Code:
Private Sub UserForm_Initialize()
  With Me.ComboBox1
    .AddItem
    .List(.ListCount - 1, 0) = "Cleveland"
    .List(.ListCount - 1, 1) = "A city in northwestern Ohio, USA"
    .AddItem
    .List(.ListCount - 1, 0) = "Cincinnati"
    .List(.ListCount - 1, 1) = "A city in southwestern Ohio, USA"
  End With
End Sub
Private Sub CommandButton1_Click()
  On Error GoTo Err_UserDefined
   FillBM "bmCityName", Me.ComboBox1.Column(0)
   FillBM "bmDescription", Me.ComboBox1.Column(1)
lbl_Exit:
   Unload Me
   Exit Sub
Err_UserDefined:
  FillBM "bmCityName", Me.ComboBox1.Value
  FillBM "bmDescription", "Not defined"
  Resume lbl_Exit
End Sub
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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
bookmarks, combobox



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking Combobox to multiple bookmarks Form updating Bookmarks - writes to the bookmarks multiple times PeterPlys Word VBA 13 01-14-2015 06:41 AM
Linking Combobox to multiple bookmarks Linking to Bookmarks savo Word 6 04-11-2013 11:04 AM
Linking Combobox to multiple bookmarks VBA code to extract specific bookmarks from multiple word files Rattykins Word VBA 4 06-27-2012 10:02 PM
Linking multiple choice questions to answers Microsoftenquirer1000 Word 1 06-11-2012 06:53 AM
Linking Combobox to multiple bookmarks linking title across multiple documents Foxtrot75 Word 1 03-02-2012 03:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft