?
Solved

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

Posted on 2008-10-01
5
Medium Priority
?
4,283 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 400 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 1600 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 1600 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

764 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