<?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 it is possible to check if an file is alway open ? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/it-is-possible-to-check-if-an-file-is-alway-open/m-p/10224286#M123142</link>
    <description>&lt;P&gt;I have an code da get some data form the model , copy an templete Excel fil , and then open it&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that If i run the code without close the excel the Excel file have the same name as the part numer the code will fail.. that I want it to do is to check if the file is open , and if it is close it before copy the templete and open it again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to do this ?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Apr 2021 08:25:19 GMT</pubDate>
    <dc:creator>Darkforce_the_ilogic_guy</dc:creator>
    <dc:date>2021-04-09T08:25:19Z</dc:date>
    <item>
      <title>it is possible to check if an file is alway open ?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/it-is-possible-to-check-if-an-file-is-alway-open/m-p/10224286#M123142</link>
      <description>&lt;P&gt;I have an code da get some data form the model , copy an templete Excel fil , and then open it&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that If i run the code without close the excel the Excel file have the same name as the part numer the code will fail.. that I want it to do is to check if the file is open , and if it is close it before copy the templete and open it again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to do this ?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 08:25:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/it-is-possible-to-check-if-an-file-is-alway-open/m-p/10224286#M123142</guid>
      <dc:creator>Darkforce_the_ilogic_guy</dc:creator>
      <dc:date>2021-04-09T08:25:19Z</dc:date>
    </item>
    <item>
      <title>Betreff: it is possible to check if an file is alway open ?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/it-is-possible-to-check-if-an-file-is-alway-open/m-p/10229338#M123193</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try following&lt;/P&gt;&lt;P&gt;Add in the Header of your rule&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AddReference "Microsoft.Office.Interop.Excel.dll"
Imports Microsoft.Office.Interop
Imports System.Runtime.InteropServices &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your rule add&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dim objApp As Excel.Application= TryCast(Marshal.GetActiveObject("Excel.Application"), Excel.Application)

If objApp IsNot Nothing Then
	Dim objBooks As Excel.Workbooks
	objBooks = objApp.Workbooks     
	     
	Dim objBook As Excel._Workbook
	For Each objBook In objBooks
		If objBook.Name= "Document-Name_With-Extension-Without_Path" Then
		'If objBook.FullName= "DocumentName_With-FullPath-and-Extension" Then 'alternative, if document name alone is not specific enough
			objBook.Close
			Exit For
		End If
	Next
End If&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 11 Apr 2021 16:59:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/it-is-possible-to-check-if-an-file-is-alway-open/m-p/10229338#M123193</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2021-04-11T16:59:27Z</dc:date>
    </item>
  </channel>
</rss>

