Remi_CG
November 4th, 1999, 09:41 AM
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
|
Click to See Complete Forum and Search --> : ListView Remi_CG November 4th, 1999, 09:41 AM 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 Lothar Haensler November 4th, 1999, 10:26 AM 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |