Hi
I need to check if a excel sheet name exists in late bound VB6.0. But I am having difficulty setting each variable and generally making the sheet code to to work. This is the code I have so far. Whats wrong with the code?
VB Code:
' Grabs filename and allocates it to mywbook frmeverythingLMP.txtFileName.Text = FileName4 pos = InStrRev(FileName4, "\") mywbook = Mid(FileName4, pos + 1, Len(FileName4) - pos + 1) ' Need to appropriately set xlsheet Set xlapp = GetObject(, "Excel.Application") Set wkbobj = xlapp.Workbooks(mywbook) Set xlbegin = wkbobj.Sheets(1) ' this variable is used further down but not shown 'Check if result sheet exists - is this right For Each xlsheet In wkbobj.Worksheets 'Check if a sheet named result exists. If xlsheet.Name <> Result Then MsgBox ("The Result sheet does not exist") Exit Sub End If Next xlsheet
thanks




Reply With Quote