Solved

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

Posted on 2008-10-01
5
4,135 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:nitin_s_shah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 100 total points
ID: 22612962
Your path does not appear to point to a template or add-in so whay are you using the Editable argument? (the True bit)
0
 

Author Comment

by:nitin_s_shah
ID: 22613026
it is working fine till yesterday but suddenly it is giving error
0
 
LVL 16

Assisted Solution

by:JohnBPrice
JohnBPrice earned 400 total points
ID: 22613753
>>it is working fine till yesterday but suddenly it is giving error

The error code is "Server threw an exception", e.g. meaningless.  Can you open the file normally with Excel?  Save it and try again?
0
 

Author Comment

by:nitin_s_shah
ID: 22621393
i am able to open with normal excel and save it also. i have installed all component again but same result.
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 400 total points
ID: 22627636
Make sure Excel is not running (if your app ever crashed or otherwise didn't properly ask Excel to quit, it will still be running forever.  Close it with Task Manager.  Step through your program to double check that SelExcelFileName is still correct (copy it and paste inot a run bar to ensure you don't have a "doh!" kind of error.)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question