HI,
Add Reference to Microsoft Excel Library whihcever is available
Public Sub WriteToExcel(Byval ExcelFileTOWriteIn as string)
Dim ExcelApp As Excel.Application
Dim WS As Excel.Worksheet
Dim i As Long
Dim RowNumAs long
Dim stra As String
Dim Strb as string
Set ExcelApp = CreateObject("excel.application")
ExcelApp.Workbooks.Open (ExcelFileTOWriteIn)
Set WS = ExcelApp.ActiveWorkbook.Sheets("Sheet1")
RowNum=1
For i=0 to List1.listcount-1
stra="a"+cstr(Rownum)
WS.Range(stra).value=Trim(List1.list(i))
RowNum = RowNum + 1
Next i
''Release all the objects u have created....
End Sub
Above code will write all the items from List box to clumn a of excel (a1, a2, a3 etc)
Hope this helps
B. Anant
|