Message 1 of 5
Need suggestions for better performance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing a program to go through a folder of parts and change the Part Number iProperty of each one, if required. The program works but is slow and requires a whole bunch of "yes" click because it keeps asking if I want to save. I have Silent Mode on. The entire sub is attached but here is the main part. Can anyone suggest improvements? Thanks - Scott
For Each oInvFile In NewFolder.Files
sExt = LCase(Mid(oInvFile.ShortName, nStr(oInvFile.ShortName, ".") + 1))
If sExt = "ipt" Or sExt = "iam" Then
Set oDoc = oInvApp.Documents.Open(oInvFile.Path)
Set oPNProp = oDoc.PropertySets(3).ItemByPropId(kPartNumberDesignTrackingProperties)
CurPN = oPNProp.Value
Debug.Print oInvFile.Name
Debug.Print CurPN
If InStr(CurPN, "347202") > 0 Then
oPNProp.Value = Replace(CurPN, "347202", SONum)
Debug.Print oPNProp.Value
End If
oDoc.Save
oDoc.Close
End If
Next
For Each oInvFile In NewFolder.Files
sExt = LCase(Mid(oInvFile.ShortName, nStr(oInvFile.ShortName, ".") + 1))
If sExt = "ipt" Or sExt = "iam" Then
Set oDoc = oInvApp.Documents.Open(oInvFile.Path)
Set oPNProp = oDoc.PropertySets(3).ItemByPropId(kPartNumberDesignTrackingProperties)
CurPN = oPNProp.Value
Debug.Print oInvFile.Name
Debug.Print CurPN
If InStr(CurPN, "347202") > 0 Then
oPNProp.Value = Replace(CurPN, "347202", SONum)
Debug.Print oPNProp.Value
End If
oDoc.Save
oDoc.Close
End If
Next