AnsweredAssumed Answered

Collections Not Assigning Correctly?

Question asked by Keaton Warn on May 10, 2019
Latest reply on Jun 18, 2019 by Gerry Maynard

I'm trying to learn how to use Collections in VBA with the attached macro (from thread However, when it gets run, it doesn't refill all of the previously filled custom properties I want to keep. Different custom property fields are left blank on different part files. 


If I run it once, certain custom property value fields are left blank. If I repopulate those emptied fields manually, and run the macro again, it keeps the manually populated entries. This makes me think that the macro is changing some property of the custom properties, but I don't know what.


EDIT: Read the previously documented stuff if you want, but it seems like  these issues have something to do with the method of "skipping" being used. This "skip" feature seems to be to remove the custom properties that are not contained in the "AddMainCustProps" sub list. 


Here are my before/after results and the accompanying Immediate Window results I'm getting.


Stainless Bolt file:





"52SMPT25" Part:






Here's a look at the Immediate Window where I'm printing the CustProps in ColCurrent, and then the Cust Props in ColMain after the Do While loop. Between runs I entered "ASDFASDFASDFASD...." manually into the custom properties that were made blank (1, 3, 6, 8, 14, and 20)




If I comment out the "blSkip" Else statement, it works.



However, if I add any extra custom properties not in the list in Sub AddMainCustProps() (list shown below), the macro hangs up and dies, probably because the blSkip variable is needed for removing the extra custom properties.


Here's how far the Immediate Window gets when the macro crashes SolidWorks: