Results 1 to 6 of 6

Thread: Error message "Old format or library type is invalid" when automating Excel

  1. #1
    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

  2. #2
    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

  3. #3
    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!



  4. #4
    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

  5. #5
    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.

  6. #6
    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.

Similar Threads

  1. Getting "INVALID CPU TYPE OR SPEED" error with ASRock Z68 Extreme3 Gen3
    By Maryland in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 10-04-2012, 11:53 AM
  2. Replies: 2
    Last Post: 17-01-2012, 01:21 PM
  3. Replies: 4
    Last Post: 29-11-2010, 10:59 AM
  4. Error "Lsass.exe-The endpoint format is invalid"
    By Sabastiaan in forum Operating Systems
    Replies: 4
    Last Post: 04-01-2010, 03:29 PM
  5. Replies: 2
    Last Post: 17-01-2007, 09:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,552,054.71094 seconds with 17 queries