<?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: Apprentice Replace Reference Issues in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6510039#M107252</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A little bit of code would be nice to see where the&amp;nbsp;problem may be.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2016 05:52:27 GMT</pubDate>
    <dc:creator>frederic.vandenplas</dc:creator>
    <dc:date>2016-08-19T05:52:27Z</dc:date>
    <item>
      <title>Apprentice Replace Reference Issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6509701#M107251</link>
      <description>&lt;P&gt;Issue 1:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;On the occasional run of my excel vba rule, after I open a file with apprentice, save it as a new name, and then try to &amp;nbsp;reassign it to modify iProps, it gives me an error. Looking in the debug window it shows the PropertySets as application error. Is there a better way to change Properties in a newly saved file in apprentice then to reopen it under the new file name, modify properties, and then flushing to file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 23:01:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6509701#M107251</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2016-08-18T23:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Apprentice Replace Reference Issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6510039#M107252</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A little bit of code would be nice to see where the&amp;nbsp;problem may be.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 05:52:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6510039#M107252</guid>
      <dc:creator>frederic.vandenplas</dc:creator>
      <dc:date>2016-08-19T05:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Apprentice Replace Reference Issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6510882#M107253</link>
      <description>&lt;P&gt;Sorry about that, I was rushed at the end of the workday. Anyways, the code I've been using with varying success - sometimes it saves fine, others it doesn't, is pasted below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm guessing I manage to confuse apprentice because I have more than one document opened/assigned to the same &lt;STRONG&gt;&lt;EM&gt;sharedapprentice As ApprenticeServerComponent&lt;/EM&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;, but can anyone confirm this?&lt;/P&gt;
&lt;P&gt;ie; in the main sub&lt;/P&gt;
&lt;P&gt;Set oParentDoc = sharedapprentice.Open("PARENTFILENAME.ipn")&lt;/P&gt;
&lt;P&gt;Set oOldDoc = sharedapprentice.Open("FILENAME.iam")&lt;/P&gt;
&lt;P&gt;Set oNewDoc = sharedapprentice.Open("FILENAME2.iam")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Call ReplaceRef(oOldDoc, oNewDoc, oParentDoc)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub ReplaceRef(oOldDoc As ApprenticeServerDocument, oNewDoc As ApprenticeServerDocument, Optional oParentDoc As ApprenticeServerDocument = vbNullString)
    
    Dim oWasReplaced As Boolean
    oWasReplaced = False
    'Replace ref in parent doc
    If Not oParentDoc Is Nothing Then
        Dim oDD As DocumentDescriptor
        For Each oDD In oParentDoc.ReferencedDocumentDescriptors
            If oDD.ReferencedFileDescriptor.FullFileName Like "*" &amp;amp; fso.GetBaseName(oOldDoc.FullFileName) &amp;amp; "." &amp;amp; fso.GetExtensionName(oOldDoc.FullFileName) Then
                On Error Resume Next
                oDD.ReferencedFileDescriptor.ReplaceReference (oNewDoc.FullFileName)
                If Err.Number &amp;lt;&amp;gt; 0 Then
                    MsgBox ("Error Found")
                End If
                On Error GoTo 0
                oWasReplaced = True
            End If
        Next
        
        With sharedapprentice.FileSaveAs
            Call .AddFileToSave(oParentDoc, oParentDoc.FullFileName)
            Call .ExecuteSave
        End With
        Call oParentDoc.Close
        Set oParentDoc = Nothing
        
    End If
    If oWasReplaced = False Then
        MsgBox ("Failed to Replace!")
    End If
        
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:08:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-replace-reference-issues/m-p/6510882#M107253</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2016-08-19T14:08:18Z</dc:date>
    </item>
  </channel>
</rss>

