Results 1 to 14 of 14

Thread: [RESOLVED] error on oXL.Workbooks.Open

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    16

    [RESOLVED] error on oXL.Workbooks.Open

    I've made a form in VB6 and compiled an exe file. Clicking on the .exe file opens the form, clicking on the button starts excel and opens a .xls file.
    The code is:

    Code:
     Option Explicit
    
       
    
       Private Sub Command1_Click()
    
          Dim oXL As Excel.Application
    
          Dim oWB As Excel.Workbook
    
          Dim MyPath, MyName, MyFile As String
    
     
    
       ' Start Excel and get Application object.
    
          Set oXL = CreateObject("Excel.Application")
    
          oXL.Visible = True
    
          
    
       ' Get file
    
             
    
        MyName = "\MySubFolder\MyXls.xls"
    
        MyPath = App.Path
    
        MyFile = MyPath & MyName
    
        oXL.Workbooks.Open MyFile
    
        oXL.Application.Visible = True
    
               
    
      Exit Sub
    
    Err_Handler:
    
           MsgBox Err.Description, vbCritical, "Error: " & Err.Number
    
       
    
       End Sub

    I get an error when excel is trying to open the .xls file (i'm sorry i can't describe the exact error, but i think it was something like a critical error in Myfile.exe caused .... in module <unknown> at....).
    the error occurs when the script is excecuting oxl.workbooks.open

    This happened on two different machines running on windows98 and office2000.

    It works fine on my PC running on windows XP and office 2002 and on my pc at work running on windows2000 and office 2002.

    I've tried different codes for the line oxl.workbooks.open like:

    oXL.Workbooks.Open (FileName:=MyFile)
    oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")
    set oWB = oXL.Workbooks.Open(FileName:=MyFile)
    set oWB = oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")

    None worked

    Please help!

    Thanks in advance!

    Cheers,
    Arie
    Last edited by arie ribbens; May 12th, 2004 at 08:29 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