I'm trying to put together a macro that will loop through all components in an assembly, including all subassemblies and the top level assembly. I need to edit the equation manager for each one and then rebuild it. I am having trouble being able to use the GetModelDoc2 method. I am getting the "Object doesn't support this property or method" error while looping through the array that I get from comps = assembly.GetComponents(False). The line that fails is Part = comps(i).GetModelDoc2. As far as I know, it is necessary to have the ModelDoc2 or AssemblyDoc in order to use GetEquationMgr. Just to be clear, I already have the code written for what I need to do to the equations, and I have tested it on assemblies and parts, and it works. The only thing I need to figure out is how to loop through the entire assembly and run that code on every single component, including the assembly itself. Anything helps, thanks!
When you get a list of components from an assembly, those are of type IComponent2 and not ModelDoc2. Use component.GetModelDoc2 to get the model, but you already knew that. This only works if the component is unsuppressed and not in lightweight mode, so you might want to start your macro by calling swAssy.ResolveAllLightWeightComponents for assemblies.
To make sure you are always using the correct types, add Option Explicit at the top of your macro (or enable the setting that adds this automatically) and click Debug > Compile before running so these types of errors are found.
You might also have just forgotten the "set" in the line of getting the modelDoc2 object.