Message 1 of 4
Loop through specific file in folder

Not applicable
07-19-2013
01:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a logic rule to replace the model reference in a idw file and then saveas using the new file reference name. I am able to do this for individual files or components within an assembly file.
However what I would like is to check through all files of a certain type (for example ipt with filenames beginning "SSUA" ) in a specific folder.
The following code from Curtis Waguespack works well for individual selected files but I would like to take it a stage further with the above parameters.
Any help would be most appreciated.?
Dim oDoc as Document oDoc = ThisDoc.Document Dim oRefFile As FileDescriptor Dim oOrigRefName As Object For Each oRefFile In oDoc.file.ReferencedFileDescriptors 'get the full file path to the original internal referencesoOrigRefName = oRefFile.FullFileName 'present a File Selection dialogDim oFileDlg As inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) oFileDlg.InitialDirectory = oOrigRefName oFileDlg.CancelError = True On Error Resume Next oFileDlg.ShowOpen() If Err.Number <> 0 Then Return ElseIf oFileDlg.FileName <> "" Then selectedfile = oFileDlg.FileName End If 'replace the referenceoRefFile.ReplaceReference (selectedfile) InventorVb.DocumentUpdate() oOrigRefName = "" Next iLogicVb.UpdateWhenDone = True Dim strNewRefName As String = Mid(selectedfile, 1, Len(selectedfile)- 4) & ".idw" 'Save copy as one new idw using the member nameThisDoc.Document.SaveAs(strNewRefName , True)