Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2014, 11:20 AM
marksm33 marksm33 is offline Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Windows 7 64bit Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Office 2013
Novice
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word
 
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
  #2  
Old 02-16-2014, 04:08 PM
macropod's Avatar
macropod macropod is offline Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Windows 7 32bit Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 01-15-2015, 06:19 PM
scarda scarda is offline Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Windows 8 Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Office 2010 64bit
Novice
 
Join Date: Jan 2015
Posts: 5
scarda is on a distinguished road
Default Link to bookmark

I'm trying to work out the code to link it to a bookmark instead of the 'Selection', any suggestions??
Reply With Quote
  #4  
Old 01-15-2015, 07:55 PM
macropod's Avatar
macropod macropod is offline Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Windows 7 64bit Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See, for example: https://www.msofficeforums.com/word-...html#post76386
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
listbox, multiselect, wordvba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word 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
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:34 AM.


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