By Adam Nagy
There is already an article on changing the file reference to another file using the Inventor API:
http://adndevblog.typepad.com/manufacturing/2012/08/replace-the-file-reference-by-inventor-api.html
If you want to combine this with the renaming of a referenced file then you can do it like so. It might be a good idea to keep the original file until the reference has been replaced:
Sub ChangeFileNameReferencedFromAssembly() Dim asmDoc As AssemblyDocument Set asmDoc = ThisApplication.ActiveDocument Dim asmCompDef As AssemblyComponentDefinition Set asmCompDef = asmDoc.ComponentDefinition Dim asmOcc As ComponentOccurrence Set asmOcc = asmCompDef.Occurrences(1) Dim partDoc As PartDocument Set partDoc = asmOcc.Definition.Document Dim fileMgr As FileManager Set fileMgr = ThisApplication.FileManager Dim oldFileName As String oldFileName = partDoc.FullFileName ' Create new file with new file name Dim newFileName As String newFileName = oldFileName + "_new.ipt" Call fileMgr.CopyFile(oldFileName, newFileName) ' Change reference ' The file you replace the reference to needs ' to be the same file or one derived from the ' original file Call asmOcc.ReferencedDocumentDescriptor. _ ReferencedFileDescriptor.ReplaceReference(newFileName) ' Delete the original file (if you want) Call fileMgr.DeleteFile(oldFileName) End Sub