Does anyone know the best way to add the selected items from a list box to the clipboard? I am using a List Box control with MultiSelect set to 2-Extended. This will allow the user to select multiple items.
If you are working with a regular listbox, it doesn't have a .value property. Chris, you might be getting that from vba? Below is code for getting all of the selected items from list1, then moving them to list 2 via the clipboard. It can be done directly(bypassing the clipboard step) so this isn't really something you might actually do, but it is a good example of getting all of the selected items into and out of the clipboard.
Code:
Private Sub Command1_Click()
Dim i As Integer
List2.Clear
Do Until i = (List1.ListCount)
Clipboard.Clear
If List1.Selected(i) = True Then
Clipboard.SetText List1.List(i)
List2.AddItem Clipboard.GetText
End If
i = i + 1
Loop
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.