Results 1 to 8 of 8

Thread: [RESOLVED] Sheet name does not exist late bound excel

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    393

    Resolved [RESOLVED] Sheet name does not exist late bound excel

    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:
    1. ' Grabs filename and allocates it to mywbook
    2.  
    3. frmeverythingLMP.txtFileName.Text = FileName4
    4. pos = InStrRev(FileName4, "\")
    5. mywbook = Mid(FileName4, pos + 1, Len(FileName4) - pos + 1)
    6.  
    7.  
    8. ' Need to appropriately set xlsheet
    9.  
    10. Set xlapp = GetObject(, "Excel.Application")
    11. Set wkbobj = xlapp.Workbooks(mywbook)
    12. Set xlbegin = wkbobj.Sheets(1)  ' this variable is used further down but not shown
    13.  
    14.  
    15. 'Check if result sheet exists - is this right
    16.  
    17. For Each xlsheet In wkbobj.Worksheets                       'Check if a sheet named result exists.
    18.         If xlsheet.Name <> Result Then
    19.            MsgBox ("The Result sheet does not exist")
    20.     Exit Sub
    21.         End If
    22. Next xlsheet

    thanks
    Last edited by gphillips; Jan 19th, 2007 at 05:50 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width