BuskyLusky
Technical User
Hi
I have a problem with this code:
------------------------------------
Dim xlTmp As Excel.Application
Dim xlSht As Excel.Worksheet
------------------------------------
Public Sub Form_Initialize()
Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open "\database.xls"
Set xlSht = xlTmp.Sheets(1)
End Sub
-----------------------------------------
Private Sub CommandButton5_Click()
Label1.Caption = xlSht.Cells.Item(5, 5)
xlTmp.Workbooks.Close
xlTmp.Quit
End Sub
--------------------------------------------
When running this pops up:
Error 91, object variable or With block variable not set.
and this line turns yellow: Label1.Caption = xlSht.Cells.Item(5, 5)
WHY????
I have a problem with this code:
------------------------------------
Dim xlTmp As Excel.Application
Dim xlSht As Excel.Worksheet
------------------------------------
Public Sub Form_Initialize()
Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open "\database.xls"
Set xlSht = xlTmp.Sheets(1)
End Sub
-----------------------------------------
Private Sub CommandButton5_Click()
Label1.Caption = xlSht.Cells.Item(5, 5)
xlTmp.Workbooks.Close
xlTmp.Quit
End Sub
--------------------------------------------
When running this pops up:
Error 91, object variable or With block variable not set.
and this line turns yellow: Label1.Caption = xlSht.Cells.Item(5, 5)
WHY????