
04-02-2003, 02:43 AM
|
|
Senior Contributor
* Expert *
|
|
Join Date: Jan 2003
Location: Newbury, UK
Posts: 1,092
|
|
You need a reference in your VB environment to Microsoft Excel.
Then try this code to take data from Excel back into VB. hen modify it for your needs:
Code:
Private Sub Command1()
Dim lRow As Long, lCol As Long, dValue As Double, dYear As Integer, dID As String
Dim obExcelApp As Excel.Application
Dim obWorkBook As Excel.Workbook
Dim c As Excel.Range
Set obExcelApp = CreateObject("Excel.Application")
Set obWorkBook = obExcelApp.Workbooks.Open("C:\temp\temp.xls")
For Each c In Excel.ActiveSheet.UsedRange
dValue = c.Value
MsgBox dValue ' Just show the data
Next c
Set obWorkBook = Nothing
Set obExcelApp = Nothing
End Sub
|
|