|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word
I have a MS Word Document (Eval1.doc) where the user clicks on an ActiveX command button (Cmnd1a). This brings up a userform (UF1) with a multiselect listbox (LB1a) on it. The user makes his/her selections, clicks the commandbutton (Cmnd1aa) beneath the listbox on the userform and the userform hides. The user now sees the MS Word Document with the selected text inserted where Cmand1a used to be. I can get this to work with a single selection listbox, but I am stuck when I change it to a multiselect listbox. I'm thinking it has something to do with setting up an array, but I need some help for someone to point me in the next direction. Here is the code that I've used so far along with a sample document. In advance, THANKS Code:
Option Explicit Private Sub UserForm_Initialize() Dim i, Str As String Str = "Rating1,Rating2,Rating3,Rating4," For i = 0 To UBound(Split(Str, ",")) LB1a.AddItem Split(Str, ",")(i) Next End Sub Private Sub CommandButton1_Click() Selection.Text = LB1a.Value Application.ScreenRefresh End Sub |
#2
|
||||
|
||||
Try something based on:
Code:
Private Sub CommandButton1_Click() Dim i As Long With Me.LB1a For i = 0 To .ListCount - 1 If .Selected(i) = True Then Selection.InsertAfter .Column(0, i) & vbCr Next End With Application.ScreenRefresh End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Link to bookmark
I'm trying to work out the code to link it to a bookmark instead of the 'Selection', any suggestions??
|
#4
|
||||
|
||||
See, for example: https://www.msofficeforums.com/word-...html#post76386
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
listbox, multiselect, wordvba |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Getting mult resps. selected in listbox to concatenate & paste at a bookmark in Word | marksm33 | Word VBA | 3 | 01-15-2015 05:59 PM |
How to use an ActiveX Control to insert a multi select listbox in Word | marksm33 | Word | 2 | 01-29-2014 05:21 PM |
How to link userform to another word document | SaneMan | Word VBA | 5 | 10-14-2011 05:12 AM |
[Word 2003] Macro's and a UserForm | xanuex | Word VBA | 0 | 10-19-2009 05:42 AM |
Moving Items | windsurfer | Outlook | 0 | 12-06-2005 06:36 AM |