Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I display vb generated data in and EXCEL SPREADSHEET

Status
Not open for further replies.

kemsu

Programmer
Aug 8, 2002
4
0
0
US
I am writing an applications that reads in data from a text file database, and manipulates the data. I want to display the result from the calculations in a Excel Spreadsheet..

Please anybody help
 
Use Excel Automation to create a spreadsheet with your data
A good reference for you would be:

Here's a code example that moves an array into an Excel spreadsheet:
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add

'Add headers to the worksheet on row 1
Set oSheet = oBook.worksheets(1)

oSheet.Range("A1").Value = Array("Product ; Account Number")
oSheet.Range("A1").Font.Bold = True
oSheet.Range("A1").EntireColumn.AutoFit

'Transfer the array to the worksheet starting at cell A2
oSheet.Range("A2").Resize(lCtr + 1).Value = dataArray

'Save the Workbook and Show it
strFileName = "c:\spreadsheet.xls"

If Dir(strFileName) <> &quot;&quot; Then Kill strFileName

oBook.SaveAs strFileName

Call ShellExecute(Me.hwnd, &quot;open&quot;, strFileName, &quot;&quot;, 0, 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top