<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: run excel macro from Inventor in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731932#M130833</link>
    <description>&lt;P&gt;This worked for me in the past:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oExcel&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Object&lt;/SPAN&gt;
&lt;SPAN&gt;oExcel&lt;/SPAN&gt; = &lt;SPAN&gt;CreateObject&lt;/SPAN&gt;(&lt;SPAN&gt;"Excel.Application"&lt;/SPAN&gt;)
  &lt;SPAN&gt;' If there is more than one macro called TestMacro,&lt;/SPAN&gt;
  &lt;SPAN&gt;' the module name would be required as in&lt;/SPAN&gt;
  &lt;SPAN&gt;'&lt;/SPAN&gt;
  &lt;SPAN&gt;' oExcel.Run "Module1.TestMacro"&lt;/SPAN&gt;
  &lt;SPAN&gt;'&lt;/SPAN&gt;
  &lt;SPAN&gt;' to differentiate which routine is being called.&lt;/SPAN&gt;
  &lt;SPAN&gt;'&lt;/SPAN&gt;
  &lt;SPAN&gt;oExcel&lt;/SPAN&gt;.&lt;SPAN&gt;Run&lt;/SPAN&gt; &lt;SPAN&gt;"TestMacro"&lt;/SPAN&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Nov 2021 07:31:42 GMT</pubDate>
    <dc:creator>theo.bot</dc:creator>
    <dc:date>2021-11-03T07:31:42Z</dc:date>
    <item>
      <title>run excel macro from Inventor</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731360#M130824</link>
      <description>&lt;P&gt;Hi, I'm trying to run an excel macro from Inventor. This is the code I wrote, however I'm not totally sure if it's ok the way I call excel application or maybe it could be shortened. Any suggestion and comment would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub Main ()&lt;/P&gt;&lt;P&gt;'Get the active assembly.&lt;BR /&gt;Set oAsmDoc = ThisApplication.ActiveDocument&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Open excel file&lt;BR /&gt;Call OpenExcelFile(BOMFileName)&lt;BR /&gt;&lt;BR /&gt;' Call sub "OrganizeData"&lt;BR /&gt;Organize_Data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Sub Organize_Data()&lt;/P&gt;&lt;P&gt;'Get excel application&lt;BR /&gt;Dim excelApp As Excel.Application&lt;BR /&gt;' Try to connect to a running instance of Excel.&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set excelApp = GetObject(, "Excel.Application")&lt;BR /&gt;&lt;BR /&gt;If Err Then&lt;BR /&gt;Err.Clear&lt;BR /&gt;&lt;BR /&gt;' Couldn't connect so start Excel. It's started invisibly.&lt;BR /&gt;Set excelApp = CreateObject("Excel.Application")&lt;BR /&gt;&lt;BR /&gt;If Err Then&lt;BR /&gt;MsgBox "Cannot access excel."&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' You can make it visible if you want. This is especially&lt;BR /&gt;' helpful when debugging.&lt;BR /&gt;excelApp.Visible = True&lt;BR /&gt;&lt;BR /&gt;' Open the excel file&lt;BR /&gt;Dim ws As WorkSheet&lt;BR /&gt;Dim wb As Workbook&lt;BR /&gt;Set wb = excelApp.ActiveWorkbook&lt;BR /&gt;Set ws = wb.Worksheets(1)&lt;BR /&gt;ws.Activate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Open excel file&lt;BR /&gt;Call OpenExcelFile(BOMFileName)&lt;BR /&gt;&lt;BR /&gt;' Call sub "OrganizeData"&lt;BR /&gt;Organize_Data&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;BR /&gt;Private Sub OpenExcelFile(FileName As String)&lt;/P&gt;&lt;P&gt;Dim excelApp As Excel.Application&lt;BR /&gt;' Try to connect to a running instance of Excel.&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set excelApp = GetObject(, "Excel.Application")&lt;BR /&gt;&lt;BR /&gt;If Err Then&lt;BR /&gt;Err.Clear&lt;BR /&gt;&lt;BR /&gt;' Couldn't connect so start Excel. It's started invisibly.&lt;BR /&gt;Set excelApp = CreateObject("Excel.Application")&lt;BR /&gt;&lt;BR /&gt;If Err Then&lt;BR /&gt;MsgBox "Cannot access excel."&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' You can make it visible if you want. This is especially&lt;BR /&gt;' helpful when debugging.&lt;BR /&gt;excelApp.Visible = True&lt;BR /&gt;&lt;BR /&gt;' Open the excel file (without dialog)&lt;BR /&gt;Dim wb As Workbook&lt;BR /&gt;Dim ExcelFilePath As Variant&lt;BR /&gt;Set wb = excelApp.Workbooks.Open(FileName)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Err Then&lt;BR /&gt;MsgBox "Impossible to open excel file."&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Access a certain sheet.&lt;BR /&gt;'Dim ws As WorkSheet&lt;BR /&gt;Set ws = wb.Worksheets(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 22:36:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731360#M130824</guid>
      <dc:creator>dibujocad</dc:creator>
      <dc:date>2021-11-02T22:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: run excel macro from Inventor</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731489#M130826</link>
      <description>&lt;P&gt;What is the goal of the macro? Can you give a bullet point list. This way forum user can best direct any further questions. For starters, I see a few sub routines being called twice and you can just declare and work with one excel object as well.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 00:27:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731489#M130826</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2021-11-03T00:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: run excel macro from Inventor</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731932#M130833</link>
      <description>&lt;P&gt;This worked for me in the past:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oExcel&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Object&lt;/SPAN&gt;
&lt;SPAN&gt;oExcel&lt;/SPAN&gt; = &lt;SPAN&gt;CreateObject&lt;/SPAN&gt;(&lt;SPAN&gt;"Excel.Application"&lt;/SPAN&gt;)
  &lt;SPAN&gt;' If there is more than one macro called TestMacro,&lt;/SPAN&gt;
  &lt;SPAN&gt;' the module name would be required as in&lt;/SPAN&gt;
  &lt;SPAN&gt;'&lt;/SPAN&gt;
  &lt;SPAN&gt;' oExcel.Run "Module1.TestMacro"&lt;/SPAN&gt;
  &lt;SPAN&gt;'&lt;/SPAN&gt;
  &lt;SPAN&gt;' to differentiate which routine is being called.&lt;/SPAN&gt;
  &lt;SPAN&gt;'&lt;/SPAN&gt;
  &lt;SPAN&gt;oExcel&lt;/SPAN&gt;.&lt;SPAN&gt;Run&lt;/SPAN&gt; &lt;SPAN&gt;"TestMacro"&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Nov 2021 07:31:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10731932#M130833</guid>
      <dc:creator>theo.bot</dc:creator>
      <dc:date>2021-11-03T07:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: run excel macro from Inventor</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10743414#M131032</link>
      <description>&lt;P&gt;I'm using this code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;AddReference "Microsoft.Office.Interop.Excel"
Imports Microsoft.Office.Interop.Excel
Class excel
	Dim excelApp As Microsoft.Office.Interop.Excel.Application
	Dim wb As Workbook

	Sub main()
		excelApp = CreateObject("Excel.Application")
		excelApp.Visible = False
		excelApp.DisplayAlerts = False
		wb = excelApp.Workbooks.Open("C:\TEMP\ex.xlsm")
		excelApp.Run("SomeMacro")
		wb.Save
		wb.Close()
		excelApp.Quit
	End Sub
End Class&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Nov 2021 19:23:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-excel-macro-from-inventor/m-p/10743414#M131032</guid>
      <dc:creator>petr.meduna</dc:creator>
      <dc:date>2021-11-08T19:23:19Z</dc:date>
    </item>
  </channel>
</rss>

