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

Multi Delete or Change Linked Excel from all parts using Ilogic Rule

filipapinto
Observer

Multi Delete or Change Linked Excel from all parts using Ilogic Rule

filipapinto
Observer
Observer

Hi, 
I want to create a rule to delete or change the excel file linked in all parts. Run it on the top assembly, and then automatically it will delete/change the linked file (Excel) in every single part and sub assemblys.

I believe de code is this:

changeOK = GoExcel.ChangeSourceOfLinked(partialOldName, newName)

*I don't understand nothing aboud coding...

Thank you

0 Likes
Reply
464 Views
1 Reply
Reply (1)

WCrihfield
Mentor
Mentor

I've never tried it before, but you can try this iLogic rule.

It is only designed to replace the source Excel file (assumes one exists), and doesn't try to delete it.

You didn't specify what conditions you want to check for when you would prefer to delete it instead of replace it.

Here's the iLogic code:

(Lines starting with an apostrophe (') are just comments, and don't effect the result of the rule.)

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
oADef.re
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
	'checking its type
	If oRefDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject And _
		oRefDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
		Continue For 'skip to the next oRefDoc
	End If
	'make this the 'active' document temporarily,
	'so the following method will hopefully work on it, instead of the main assembly
	oRefDoc.Activate
	'if you specify an empty string for the first name, it will replace any reference that is currently there
	'replace the second name with the path and name of your new excel file.
	Dim oChanged As Boolean = GoExcel.ChangeSourceOfLinked("", "C:\Temp\NewExelReference.xlsx")
	'it will be True if it succeeded
	If oChanged = False Then
		MsgBox("It failed to change the source Excel file for:" & vbCrLf & _
		oRefDoc.FullFileName,vbOKOnly+vbInformation,"")
	End If
Next

There is likely a better way to check for this link, but since I rarely attempt to manage it by code, I haven't seen another way yet.

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

If you have time, please... Vote For My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes