Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi Scott.Hallmark,

 

It's difficult to know without seeing the whole picture, but try something like this, maybe... it runs without issue for my testing.

 

Edit: Also my guess would be that one or more occurrence name is too short or something, and so the Left or Mid lines are returning an error.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

FilePrefix = "Test_"
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
   	Dim oName As String 
   	oName = oOccurrence.Name
	oName2 = Left(oName, 1)
	oName3 = Left(oName, 3)
	oName4 = Mid(oName, 4)
	If oName2 = "-" Then 
		oOccurrence.Name = FilePrefix & oName
	Else If oName3 <> FilePrefix Then
		oOccurrence.Name = FilePrefix & oName4
	End If
Next