Here is what i came up with, hope it helps:
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oInv As New Inventor.ApprenticeServerComponent
Dim oAssy As Inventor.ApprenticeServerDocument
Dim oSave As Inventor.FileSaveAs
Dim blnSave As Boolean
Try
Dim oDirs() As DirectoryInfo = New DirectoryInfo("F:\INVENTOR_Drawings").GetDirectories("*", SearchOption.AllDirectories)
For Each oDir As DirectoryInfo In oDirs
If ProcessDir(oDir.FullName) Then
If oDir.GetFiles("*.iam").Length > 0 Then
Dim oFiles() As FileInfo = oDir.GetFiles("*.iam")
For Each oFile As FileInfo In oFiles
oAssy = oInv.Open(oFile.FullName)
blnSave = False
For Each oPart As Inventor.ReferencedFileDescriptor In oAssy.ReferencedFileDescriptors
If InStr(1, oPart.FullFileName, "x09767.ipt", CompareMethod.Text) > 0 Then
Call oPart.PutLogicalFileNameUsingFull("f:\inventor_drawings\standard_ipt\x_pn\x09770.ipt")
blnSave = True
End If
Next
If blnSave Then
oSave = oInv.FileSaveAs
oSave.AddFileToSave(oAssy, oAssy.FullFileName)
oSave.ExecuteSave()
End If
oAssy.Close()
Next
End If
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function ProcessDir(ByVal Name As String) As Boolean
Dim blnRet As Boolean = True
If InStr(1, Name, "content center", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "tube and pipe", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "design accelerator", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "oldversions", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "imported components", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "cable and harness", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "hoffman enclosures", CompareMethod.Text) > 0 Then
blnRet = False
End If
If InStr(1, Name, "customer files", CompareMethod.Text) > 0 Then
blnRet = False
End If
Return blnRet
End Function
End Class