I am trying to open an existing Excel file from an Access and trying to send it a value and based on some calculations it returns some value back to Access which i need to display in the report. the problem is when i am trying to open the excel file it does not open it .
My code is as follows:
Dim objxl As Excel.Application
Dim objwb As Excel.Workbook
Dim objSheet As Excel.Worksheet
Set objxl = CreateObject("Excel.Application")
Set objwb = objxl.Workbooks.Open("c:\work\calculator.xls")
Set objSheet = objwb.Worksheets(1)
objSheet.Activate
objSheet.Cells(9, b).Value = Me.txtAvgCCS
Dim x As Integer
x = objSheet.Cells(15, b).Value
If x <> 0 Then
txtP001 = x
End If
objwb.Close
objxl.Quit
Set objSheet = Nothing
Set objwb = Nothing
Set objxl = Nothing
But it gives the following error "Application defined or object defined error"
When i ran the debug window I found that the objwb does not have any value at all...
How do I go about solving this issue.
Thanks in advance.
My code is as follows:
Dim objxl As Excel.Application
Dim objwb As Excel.Workbook
Dim objSheet As Excel.Worksheet
Set objxl = CreateObject("Excel.Application")
Set objwb = objxl.Workbooks.Open("c:\work\calculator.xls")
Set objSheet = objwb.Worksheets(1)
objSheet.Activate
objSheet.Cells(9, b).Value = Me.txtAvgCCS
Dim x As Integer
x = objSheet.Cells(15, b).Value
If x <> 0 Then
txtP001 = x
End If
objwb.Close
objxl.Quit
Set objSheet = Nothing
Set objwb = Nothing
Set objxl = Nothing
But it gives the following error "Application defined or object defined error"
When i ran the debug window I found that the objwb does not have any value at all...
How do I go about solving this issue.
Thanks in advance.