Delete unused parameters

Delete unused parameters

Anonymous
Not applicable
871 Views
1 Reply
Message 1 of 2

Delete unused parameters

Anonymous
Not applicable

I am looking for iLogic code to delete all parameters that have a value of 0 or nothing. I am found code that will delete specific parameters, but not one that will loop through all of them and delete them.

 

Thanks,

0 Likes
872 Views
1 Reply
Reply (1)
Message 2 of 2

Owner2229
Advisor
Advisor

Here you go. Comment out / remove the blue lines if you want to remove all un-used parameters.

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
Dim oParams As Parameters = oCD.Parameters
For Each oPara As Parameter In oParams
	If oPara.InUse Then Continue For
	Dim oVal As String = oPara.Value
	If oVal <> "0" And oVal <> vbNullString Then Continue For
	oPara.Delete()
Next
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods