<?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: Inventor crashes after oDoc.Close (VBA) in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784099#M115981</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1195126"&gt;@rogmitch&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;It is difficult to diagnose a crash but it could be a timing issue. &amp;nbsp;You could try adding a &amp;nbsp;DoEvents statment after the Execute or/and Close commands. &amp;nbsp;Occasionally I have seen this help in my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Roger Mitchell&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;And how would that look exactly? I haven't worked with the DoEvents statement yet.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Aug 2015 07:29:10 GMT</pubDate>
    <dc:creator>dominiek_vanwest</dc:creator>
    <dc:date>2015-08-24T07:29:10Z</dc:date>
    <item>
      <title>Inventor crashes after oDoc.Close (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5781487#M115979</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following VBA code (to Update, Save, CheckIn and Close the file):&lt;/P&gt;&lt;PRE&gt;Public Sub UpdateSaveCheckinClose()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    oDoc.Update
    oDoc.Save2 (True)
    
    Dim oCtrlDef As ControlDefinition
    Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions("VaultCheckinTop")
    oCtrlDef.Execute
    
    oDoc.Close
End Sub&lt;/PRE&gt;&lt;P&gt;But Inventor crashes right after oDoc.Close.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I add the following after oDoc.close, I have no problem.&lt;/P&gt;&lt;PRE&gt;MsgBox ("Document closed")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does Inventor crashes without the MsgBox?&lt;/P&gt;&lt;P&gt;And how can I solve this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Dominiek&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 08:34:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5781487#M115979</guid>
      <dc:creator>dominiek_vanwest</dc:creator>
      <dc:date>2015-08-21T08:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor crashes after oDoc.Close (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5782891#M115980</link>
      <description>&lt;P&gt;It is difficult to diagnose a crash but it could be a timing issue. &amp;nbsp;You could try adding a &amp;nbsp;DoEvents statment after the Execute or/and Close commands. &amp;nbsp;Occasionally I have seen this help in my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Roger Mitchell&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 23:26:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5782891#M115980</guid>
      <dc:creator>rogmitch</dc:creator>
      <dc:date>2015-08-21T23:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor crashes after oDoc.Close (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784099#M115981</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1195126"&gt;@rogmitch&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;It is difficult to diagnose a crash but it could be a timing issue. &amp;nbsp;You could try adding a &amp;nbsp;DoEvents statment after the Execute or/and Close commands. &amp;nbsp;Occasionally I have seen this help in my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Roger Mitchell&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;And how would that look exactly? I haven't worked with the DoEvents statement yet.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 07:29:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784099#M115981</guid>
      <dc:creator>dominiek_vanwest</dc:creator>
      <dc:date>2015-08-24T07:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor crashes after oDoc.Close (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784620#M115982</link>
      <description>&lt;P&gt;Just as an example from my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set oProjectionEntity = osketch.AddByProjectingEntity(oPartCompDef.WorkAxes.Item(3)) 'Z axis&lt;BR /&gt;oProjectionEntity.Construction = True&lt;BR /&gt;DoEvents&lt;/P&gt;&lt;P&gt;more code...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 13:40:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784620#M115982</guid>
      <dc:creator>rogmitch</dc:creator>
      <dc:date>2015-08-24T13:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor crashes after oDoc.Close (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784790#M115983</link>
      <description>&lt;P&gt;I put the DoEvents before oDoc.Close and it works!&lt;/P&gt;&lt;P&gt;I haven't got a crash anymore.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What does the DoEvents statement actually do?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 14:48:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5784790#M115983</guid>
      <dc:creator>dominiek_vanwest</dc:creator>
      <dc:date>2015-08-24T14:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor crashes after oDoc.Close (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5785190#M115984</link>
      <description>&lt;P&gt;Essentially it forces all Window messages that are queued to&amp;nbsp;be processed while the current thread is suspended. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This means that any process that is necessary to ensure the correct behaviour of the current thread willl now be finished&amp;nbsp;and hence the current thread can continue to completion&amp;nbsp;without crashing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Roger Mitchell&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 16:58:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-crashes-after-odoc-close-vba/m-p/5785190#M115984</guid>
      <dc:creator>rogmitch</dc:creator>
      <dc:date>2015-08-24T16:58:59Z</dc:date>
    </item>
  </channel>
</rss>

