Hi all,
I did the following coding for retrieving some vaues from a excel sheet but I am facing problem in the red colour line "IsEmpty".
Run-Time error '1004':
Method 'Worksheets' of object '_Global' failed
I am doing this in VB 6.0 (Not in Excel)
Help please.
advance
Thanks
Raj
VB Code:
[FONT=Courier New]Sub RetValFrmxl(ChuckTyp As String, Ports As String) Dim XlApp1 As Object Dim XlApp As Object Dim ExcelWasNotRunning As Boolean Dim ActSht As Excel.Worksheet Dim i, j, k As Long Set XlApp1 = GetObject(App.Path & "\data.XLS") XlApp1.Application.Visible = True XlApp1.Parent.Windows(1).Visible = True XlApp1.Worksheets(Ports).Activate Set ActSht = XlApp1.ActiveSheet i = 1 j = 0 [COLOR=Sienna] Do While Not IsEmpty(Worksheets(Ports).Cells(i, 1))[/COLOR] If ActSht.Cells(i, 1).Value = "" Then Exit Do End If If ActSht.Cells(i, 1).Value = ChuckTyp Then For j = 2 To 8 If j = 2 Then A = ActSht.Cells(i, j).Value Debug.Print A ElseIf j = 3 Then B = ActSht.Cells(i, j).Value Debug.Print B ElseIf j = 4 Then C = ActSht.Cells(i, j + 1).Value Debug.Print C ElseIf j = 5 Then D = ActSht.Cells(i, j + 2).Value Debug.Print D ElseIf j = 6 Then E = ActSht.Cells(i, j + 2).Value Debug.Print E ElseIf j = 7 Then F = ActSht.Cells(i, j + 2).Value Debug.Print F ElseIf j = 8 Then G = ActSht.Cells(i, j + 2).Value Debug.Print G End If Next End If i = i + 1 Loop If ExcelWasNotRunning = True Then XlApp.Application.Quit End If Set XlApp = Nothing End Sub[/FONT]




Reply With Quote