Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-03-2010
Member
 
Join Date: Jul 2006
Posts: 128
Error message "Old format or library type is invalid" when automating Excel

Hi friends,
When I am trying to automate an Excel I am getting an error. I am trying to automate Microsoft Excel with Microsoft Visual Basic. NET, and Microsoft Visual C + +. Everytime I am trying to automate, I get an error message stating that "Old format or library type is invalid".!! I need your help for fixing this error. Hope that someone would understand my problem and will help me soon.!!
__________________
"Every man is guilty of all the good he did not do". - Voltaire
Reply With Quote
  #2  
Old 30-03-2010
Member
 
Join Date: Jul 2006
Posts: 273
Re: Error message "Old format or library type is invalid" when automating Excel

This error occurs when calling an Excel method when the following conditions are met :
  1. You use early binding to call the method.
  2. The method requires an LCID (locale identifier).
  3. You run an English version of Excel, but the region of the computer are configured for a language other than English.
So check the above conditions and your problem will be solved.
__________________
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signatureto help him gain world domination
Reply With Quote
  #3  
Old 30-03-2010
Member
 
Join Date: Aug 2006
Posts: 222
Re: Error message "Old format or library type is invalid" when automating Excel

The mentioned below is the common cause of the error that you are getting. If the client computer running the English version of Microsoft Excel and the locale of the current user is configured for a language other than English, Excel will attempt to locate the module language support language configured. The error occurs if the module language support is not found. So I would like to suggest you to check the settings properly.
__________________
Just a reply to say thank you for these links and posts I have a lot to read and learn now!


Reply With Quote
  #4  
Old 30-03-2010
Member
 
Join Date: Aug 2006
Posts: 209
Re: Error message "Old format or library type is invalid" when automating Excel

To avoid this problem, you can follow the steps :
  • Defining the cultural thread active on English before instantiate Excel. For example :
    Code:
    Dim oApp As New Excel.Application()
    oApp.Visible = True
    oApp.UserControl = True
    Dim oBooks As Object = oApp.Workbooks
    Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
    oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci)
  • Use late binding instead of early binding.
__________________
Blessings to you
Reply With Quote
  #5  
Old 30-03-2010
Member
 
Join Date: Jul 2006
Posts: 339
Re: Error message "Old format or library type is invalid" when automating Excel

First you will have to verify that the locale of the computer are set to a language other than English. For doing this, follow the steps :
  • In the Windows Control Panel, double-click Regional Options.
  • On the General tab, select a location, then click OK.
If you are using the Windows XP, then installing the Multilingual User Interface Pack Microsoft Office XP may also help you.
Reply With Quote
  #6  
Old 30-03-2010
Member
 
Join Date: May 2008
Posts: 353
Re: Error message "Old format or library type is invalid" when automating Excel

The following are is the way for reproducing the problem :
  1. Start Microsoft Visual Studio.
  2. In the File menu, point to New, and then click Project. In the dialog New Project under Project Types, click Visual Basic Projects. Under Templates, click Windows Application, then click OK.
  3. Add a reference to the Object Library Microsoft Excel.
  4. In the View menu, click Toolbox, then add a button to Form1.
  5. To display the code window for the form, double-click Button1.
  6. In the code window, replace the following code :
    [
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim oApp As Object
        Dim oDoc As Object
        oApp = CreateObject("Excel.Application")
        oApp.Visible = True
        oDoc = oApp.Workbooks.Add
        oDoc.Close()
        oApp.Quit()
        oDoc = Nothing
        oApp = Nothing
    End Sub
  7. Add the following code at the beginning of Form1.vb :
    Code:
    Option Strict Off
  8. Press F5 to build and run the program.
  9. To generate the error, click Button1.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Error message "Old format or library type is invalid" when automating Excel"
Thread Thread Starter Forum Replies Last Post
Getting "INVALID CPU TYPE OR SPEED" error with ASRock Z68 Extreme3 Gen3 Maryland Motherboard Processor & RAM 3 10-04-2012 11:53 AM
Getting error that "specified dimension is not valid for the current chart type" on Excel RYAN$ MS Office Support 2 17-01-2012 01:21 PM
Excel Error message: "External table is not in the expected format" X-quisite Windows Software 4 29-11-2010 10:59 AM
Error "Lsass.exe-The endpoint format is invalid" Sabastiaan Operating Systems 4 04-01-2010 03:29 PM
Project Web Access via IE7: "Export Grid to Excel" cause VBSCRIPT (error) message: "The activeX control on which this feature depends could not be created" Theo-Dore Microsoft Project 2 17-01-2007 09:47 PM


All times are GMT +5.5. The time now is 09:36 AM.