Link to home
Start Free TrialLog in
Avatar of unreal400
unreal400

asked on

Copy data out of a listview

I want to be able to copy selected rows  or columns out a listview to the clipboard then be able to paste the resuts into excel and have the data inserted in the colums so it is formatted  the same way

so if the listview is like this
data 1 |  data2  | data 3
row2a |  data2  | data 3
 
I want to be able to highlight those 2 rows in the listview and copy them  then paste them into excel or whatever and have them formatted in the rows and colums that were in the listview.

Is there an easy way to do this?

Kelly



ASKER CERTIFIED SOLUTION
Avatar of plq
plq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aelatik
Private Sub Form_Load()
    Clipboard.Clear
For i = 1 To 3
    ListView1.ListItems.Add , , "test"
    ListView1.ListItems.Item(i).SubItems(1) = "test1" & i
    ListView1.ListItems.Item(i).SubItems(2) = "test2" & i
Next i
   
    Dim BUFFER
    For i = 1 To ListView1.ListItems.Count
        BUFFER = BUFFER & ListView1.ListItems.Item(i).Text & vbTab & ListView1.ListItems.Item(i).SubItems(1) & vbTab & ListView1.ListItems.Item(i).SubItems(2) & vbCrLf
    Next i
        Clipboard.SetText BUFFER
End Sub