View Single Post
 
Old 02-09-2014, 11:20 AM
marksm33 marksm33 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Jan 2014
Posts: 12
marksm33 is on a distinguished road
Exclamation 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
Reply With Quote