![]() |
#1
|
|||
|
|||
![]()
I'm after some thoughts on creating a listbox on a userform (with multiple selections available), then have this linked to a particular bookmark. However the text that appears in the listbox isn't all of the wording I'd like to add, so I'm thinking of creating a second column.
Below is the first part of the code that I've worked out, however I want to try link a selection to a bookmark. Private Sub UserForm_Initialize() With Me.ListBox1Area .ColumnCount = 2 .ColumnWidths = .Width & ",0" .AddItem .List(.ListCount - 1, 0) = "" .AddItem .List(.ListCount - 1, 0) = "Area 1" .List(.ListCount - 1, 1) = "Description...." .AddItem .List(.ListCount - 1, 0) = "Area 2" .List(.ListCount - 1, 1) = "Description...." .ListIndex = 0 End With End Sub |
#2
|
||||
|
||||
![]()
You don't link an item to a bookmark but you could add a column to hold the bookmark name and then have another macro to do something when the selection is made. eg
Private Sub ListBox1Area_OnChange() 'your code here End Sub |
#3
|
|||
|
|||
![]()
That's what I'm trying to work out, the code to insert the selection (from the listbox) at the bookmark. As I have another column in the listbox, I would need to differentiate which column belongs to a particular bookmark
|
#4
|
||||
|
||||
![]()
Assuming you are not using a multi-select listbox, the code might look like this if you also assume you want to put the contents of the second column into the location of the bookmark name which appears in the first column
ActiveDocument.Bookmarks(ListBox1Area.Value).range .text = ListBox1Area.List(ListBox1Area.ListIndex, 1) |
#5
|
|||
|
|||
![]()
I am hoping on using a multi-select listbox, how would this change the code?
|
#6
|
||||
|
||||
![]() |
![]() |
Tags |
listbox bookmark |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
marksm33 | Word VBA | 3 | 01-15-2015 07:55 PM |
![]() |
marksm33 | Word VBA | 3 | 01-15-2015 05:59 PM |
![]() |
CatMan | Excel | 1 | 08-08-2014 09:41 AM |
![]() |
Mijin | Word | 2 | 09-22-2011 03:14 AM |
![]() |
b0x4it | Word VBA | 4 | 05-26-2011 01:14 AM |