Link to home
Start Free TrialLog in
Avatar of Nitin Shah
Nitin ShahFlag for India

asked on

run-time error '2147417851' (80010105') method of 'open' of object 'workbooks' failed

run-time error '2147417851' (80010105')  method of  'open' of object 'workbooks' failed while opening excel -workshooet in vb 6 program

program coding  
-----------------------
Private Sub OpenExcelDataBase()
'**********************************************************************
'**  CONVERT DATA FROM EXCEL TO SQL DATABASE
'**********************************************************************
    Dim fs
    Set fs = CreateObject("scripting.filesystemobject")
    SelExcelFileName = Trim(ctlSELEXECLFILENAME.Text)
    If Trim(Len(SelExcelFileName)) = 0 Then
       MsgBox "Select Excel file", vbCritical, Me.Caption
       cmdFILESEARCH.SetFocus
       Exit Sub
    End If
'**********************************************************************
    If Not fs.FileExists(SelExcelFileName) Then
        MsgBox "Warning - Not a valid Excel file name ", vbCritical
        Exit Sub
    End If
'**********************************************************************
    XLSBK.DefaultFilePath = SelExcelFileName
'**********************************************************************
    XLSBK.Workbooks.Open SelExcelFileName, , , , , , , , , True  ' <-----here erroe is generated---->
    XLSBK.Visible = False
'**********************************************************************
    If Trim(Len(Trim(ctlEXCELNO.Text))) = 0 Then
       ctlEXCELNO.Text = "0"
    End If
'**********************************************************************
    If Trim(Len(Trim(ctlEXECLHEADER.Text))) = 0 Then
       ctlEXECLHEADER.Text = "0"
    End If
'**********************************************************************
    SelExcelNo = Trim(ctlEXCELNO.Text)
    SelExcelHeaderNo = Trim(ctlEXECLHEADER.Text)
    If SelExcelHeaderNo = 0 Then
       SelExcelHeaderNo = 1
    Else
       SelExcelHeaderNo = SelExcelHeaderNo + 1
    End If
    If SelExcelNo = 0 Then
       SelExcelNo = 1
    Else
       SelExcelNo = SelExcelNo + 1
    End If
    Set XLwsh = XLSBK.Sheets(SelExcelNo)
'**********************************************************************


vb-excel-error.bmp
SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nitin Shah

ASKER

it is working fine till yesterday but suddenly it is giving error
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i am able to open with normal excel and save it also. i have installed all component again but same result.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial