0

We recently upgraded from Inventor 2017->2021 and now some VBA code doesn't work anymore. It all comes down to not be able to not correctly start an Excel.Application (but also Word or Powerpoint) via VBA from Inventor. See the code examples below. I have the references set correctly and I can declare a variable as Excel.Application. But when I declare a variable as Excel.Application, and then create an object using CreateObject("Excel.Application") it gives me this error. enter image description here

When I declare the variable just as an Object, everything works. Later on I still can't assign it to an Excel.Application variable.

I can use all other variable types like Workbook, Range etc. perfectly. The only thing not working is the Excel.Application variable.

When I run the same code from Excel or Word, it works without any problems. When I try to start other objects like Inventor.Application or AutoCAD.Application it doesn't give this issue.

The base code that should work, but doesn't from Inventor, but does work from Excel/Word:

Sub StartExcel()
    
    Dim oXL As Excel.Application
    Set oXL = CreateObject("Excel.Application")
    
    oXL.Visible = True
    oXL.Workbooks.Add
    
End Sub

The code which does work:

Sub StartExcel()
    
    Dim oXL As Object
    Set oXL = CreateObject("Excel.Application")
    
    oXL.Visible = True
    oXL.Workbooks.Add
    
End Sub

Does anybody have an idea why it's not working?

Software details: Inventor version is 2021 Office 365 (object libraries 16.0) VDI Citrix environment Windows 10 version 2004

Majjek
  • 41
  • 3
  • Does the following work in `Inventor`: `Dim oXL As New Excel.Application`? I mean either you do this, or `Dim oXL As Object: Set oXL = CreateObject("Excel.Application")`: Early bound or late bound. – VBasic2008 Oct 28 '20 at 11:37
  • Hi, thanks for your quick response. I forgot to mention that I already tried that. It gives me the same error.. – Majjek Oct 28 '20 at 12:12

0 Answers0