<?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: iLogic error handling on export PDF - &amp;quot;File in use&amp;quot; in Inventor Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/6996658#M284085</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4496358"&gt;@Wowbagger2&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before "publish document" with the "save copy as" command at the end of your code, you could add these lines :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;DocPDF&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;AcroExch.AVDoc&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Check if PDF document exists&lt;/SPAN&gt;
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;System&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;IO&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;File&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Exists&lt;/SPAN&gt;&lt;SPAN&gt;(oDataMedium.FileName&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Close it without saving&lt;/SPAN&gt;
&lt;SPAN&gt;DocPDF&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Open&lt;/SPAN&gt;&lt;SPAN&gt;(oDataMedium.FileName&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;DocPDF&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Close&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;True&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit : I precise it will work only if the PDF document is open on your PC. If open by an other user...I think there is no way to solve this.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2017 08:50:51 GMT</pubDate>
    <dc:creator>ThomasB44</dc:creator>
    <dc:date>2017-04-05T08:50:51Z</dc:date>
    <item>
      <title>iLogic error handling on export PDF - "File in use"</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/6996416#M284084</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found this script in another thread (&lt;A href="https://forums.autodesk.com/t5/inventor-forum/ilogic-rule-quot-auto-export-pdf-on-save-quot/td-p/5388693" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-forum/ilogic-rule-quot-auto-export-pdf-on-save-quot/td-p/5388693&lt;/A&gt;) to export/save a pdf from a drawing upon save. This works really good but I would like to add a error message if the file was unable to be saved/updated, most likely cause the PDF is open or in use somewhere. As of now the error that shows up is&amp;nbsp;&amp;nbsp;"(Exception from HRESULT: 0x80004005 (E_FAIL))" I would like to simply add a MessageBox instead. Happy if anyone could help me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the script:&lt;/P&gt;&lt;PRE&gt;' Get the PDF translator Add-In.
Dim PDFAddIn As TranslatorAddIn
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

' Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
'oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If

PDFDirectory = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension

If ThisDoc.Path =  "" Then
MessageBox.Show("PDF file not created, click Save button again for PDF creation.", "iLogic")
Return 'exit rule
Else
oDataMedium.FileName = PDFDirectory &amp;amp; "\" &amp;amp; oFileName &amp;amp; ".PDF"
End If

'Publish document.
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'Launch the PDF file in whatever application Windows is set to open this document type with
'i = MessageBox.Show("Preview the PDF file?", "PDF Preview",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'If i = vbYes Then ThisDoc.Launch(oDataMedium.FileName)

On Error
MessageBox.Show("PDF not saved, file is in use. Please close the PDF-document and try again", "iLogic")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Fredrik&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 06:16:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/6996416#M284084</guid>
      <dc:creator>Wowbagger2</dc:creator>
      <dc:date>2017-04-05T06:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic error handling on export PDF - "File in use"</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/6996658#M284085</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4496358"&gt;@Wowbagger2&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before "publish document" with the "save copy as" command at the end of your code, you could add these lines :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;DocPDF&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;CreateObject&lt;/S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SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit : I precise it will work only if the PDF document is open on your PC. If open by an other user...I think there is no way to solve this.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 08:50:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/6996658#M284085</guid>
      <dc:creator>ThomasB44</dc:creator>
      <dc:date>2017-04-05T08:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic error handling on export PDF - "File in use"</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7002467#M284086</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3343209"&gt;@ThomasB44&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for that suggestion but I'm wondering, it seems to me pretty much the only error that can occur when trying to re save the PDF is that Inventor cannot access the file because it is already in use somewhere. Would it not be possible to have a MessageBox that pops up if the save failed for some (any!) reason?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 11:27:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7002467#M284086</guid>
      <dc:creator>Wowbagger2</dc:creator>
      <dc:date>2017-04-07T11:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic error handling on export PDF - "File in use"</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7002871#M284087</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4496358"&gt;@Wowbagger2&lt;/a&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it not be possible to have a MessageBox that pops up if the save failed for some (any!) reason?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sure it would be possible, you can try these lines at the end of your code.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;'Publish document.&lt;BR /&gt;Try
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)&lt;BR /&gt;Catch&lt;BR /&gt;'Fail to save, an error occurs&lt;BR /&gt;MessageBox.Show("PDF not saved, file is in use. Please close the PDF-document and try again", "iLogic")&lt;BR /&gt;End Try&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:10:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7002871#M284087</guid>
      <dc:creator>ThomasB44</dc:creator>
      <dc:date>2017-04-07T14:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic error handling on export PDF - "File in use"</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7002944#M284088</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;...&amp;nbsp;Would it not be possible to have a MessageBox that pops up if the save failed for some (any!) reason?
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi fredrik.carlsson,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just change the last line to read as you see fit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;MessageBox.Show("PDF not saved.", "iLogic")&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:28:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7002944#M284088</guid>
      <dc:creator>Curtis_W</dc:creator>
      <dc:date>2017-04-07T14:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic error handling on export PDF - "File in use"</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7006217#M284089</link>
      <description>&lt;P&gt;Thank you all. I think this solution will be sufficient!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 09:58:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/ilogic-error-handling-on-export-pdf-quot-file-in-use-quot/m-p/7006217#M284089</guid>
      <dc:creator>Wowbagger2</dc:creator>
      <dc:date>2017-04-10T09:58:56Z</dc:date>
    </item>
  </channel>
</rss>

