title: VB6 program fails opening Excel 2007 with Automation Error Library not registered
body: <p>I created this VB6 program on my Windows 7 32bit machine with Office 2010 32bit, which runs fine. Tested it on a Windows 8 64 bit machine with Office 2013 32bit, it works. On one machine with, Windows 7 64 bit and Office 2007(32 bit only) it throws an error during the following piece of code.</p>
  
  <p>The actual error message: </p>
  
  <blockquote>
    <p>Run-time Error –2147319779 (8002801d) Automation error, Library not
    registered</p>
  </blockquote>
  
  <p>VB6 Code:</p>
  
  <pre><code>If (excel_app Is Nothing) Then
      Set excel_app = CreateObject("Excel.Application")
  Else
      Set excel_app = GetObject(, "Excel.Application")
  End If
  
  excel_app.Visible = True
  excel_version = excel_app.Application.Version
  Set wBook = excel_app.Workbooks.Open(directory_path &amp; "\templates\book1.xlsm")
  </code></pre>
  
  <p>So it is throwing the error when I open book1. It actual does open it and it has a macro run on Workbook_Open(), this runs right through seemly fine. After it finishes and processing of the program returns to the VB6 program it throws the error.</p>
  
  <p>Here are the project references:
  <img src="https://i.stack.imgur.com/tdw6n.jpg" alt="enter image description here"></p>
  
  <p>Has anyone come across this and what would be the fix?</p>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>I am obviously doing something wrong here my error handler is throwing an error. </p>
  
  <p>I did try one other thing and that was removed "Set wBook = " and it didn't throw an error. I have placed "Set wBook = " back since then, as I do need it further on in my code.</p>
  
  <pre><code>    Dim wBook As Workbook
      Dim excel_app As Object
  
      On Error GoTo trialhandler
  
      If (excel_app Is Nothing) Then
          Set excel_app = CreateObject("Excel.Application")
      Else
          Set excel_app = GetObject(, "Excel.Application")
      End If
  
      excel_app.Visible = True
      excel_version = excel_app.Application.Version
      Set wBook = excel_app.Workbooks.Open(directory_path &amp; "\templates\book1.xlsm")
  
      MsgBox ("Exiting")
      Exit Sub
  trialhandler:
  
      Dim source_string As String
      source_string = excel_app.Source 'Error here
      MsgBox ("My Error 1:" &amp; source_string)
      excel_app.Err
      MsgBox ("My Error 2:" &amp; excel_app.Err.Number &amp; "  " &amp; excel_app.Err.Description)
  
      Exit Sub
  </code></pre>
  
  <p>I had Office 2013 installed on this previously, then uninstalled it and placed 2007 on it, could this have any impact? Or the fact that I have created this program with reference to Excel 2010 and now I'm trying to run it against Office 2007? Though it works on the other machine with 2013. Grasping at straws here.</p>
  
  <p><strong>[EDIT 2]</strong></p>
  
  <p>It has passed the initial error to throw exactly the same error later on. This piece imports an mdb table. There must be some early binding left over</p>
  
  <pre><code>    With wBook.Worksheets("Seal Register").ListObjects.Add(SourceType:=0, Source:=Array( _
          "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" &amp; db_full_path &amp; ";" _
          , _
          "Mode=ReadWrite;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";" _
          , _
          "Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;" _
          , _
          "Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;" _
          , _
          "Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;" _
          , _
          "Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False"), _
          Destination:=Range("A" &amp; row_number)).QueryTable
          .MaintainConnection = False
          .CommandType = xlCmdTable
          .CommandText = Array(db_table_name)
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .PreserveFormatting = True
          .RefreshOnFileOpen = False
          .BackgroundQuery = True
          .RefreshStyle = 1
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .RefreshPeriod = 0
          .PreserveColumnInfo = True
          .SourceDataFile = db_full_path
          .ListObject.DisplayName = "Table_" &amp; db_table_name
          .Refresh BackgroundQuery:=False
      End With
  </code></pre>