|
-
November 4th, 1999, 10:41 AM
#1
ListView
How do u place what you have in listview into excel. Do u need to use OLE? Please help i'm in dire strays.....see I can't even spell...help fast
-
November 4th, 1999, 11:26 AM
#2
Re: ListView
this code has been tested in VB 6 and NT 4
private Sub Command1_Click()
Dim i as ListItem
Dim j as Integer
for j = 1 to 5
set i = l.ListItems.Add
i.Text = "col1"
i.SubItems(1) = "col2"
i.SubItems(2) = "col3"
next j
Dim x as Excel.Application
set x = CreateObject("Excel.Application")
Dim w as Excel.Workbook
set w = x.Workbooks.Add
x.Visible = true
Dim row
Dim col
Dim strRange as string
for row = 1 to l.ListItems.Count
strRange = "A" & row
w.ActiveSheet.Range(strRange).Value = l.ListItems(row).Text
for col = 1 to l.ColumnHeaders.Count - 1
strRange = Chr(Asc("A") + col) & row
Debug.print strRange
w.ActiveSheet.Range(strRange).Value = l.ListItems(row).SubItems(col)
next
next
End Sub
it adds a few lines to a list view (reportmode) and transfers the data to excel.
There may be more efficient methods, but it works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|