Solved

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

Posted on 2008-10-01
5
3,968 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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.

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now