Try this macro:
Dim swApp As SldWorks.SldWorks
Dim swAssy As SldWorks.AssemblyDoc
Set swApp = Application.SldWorks
Set swAssy = swApp.ActiveDoc
Dim vComps As Variant
vComps = swAssy.GetComponents(False)
MsgBox "Total number of components: " & UBound(vComps) + 1
Regards, Artem Taturevych | Snr. Developer | IC3D ANZ
IC3DSteel – New Steel Solution for SolidWorks
translationXpert – SolidWorks files language translator
Thanks for that Artem, it counts the components and works but.....it is not exactly what I am after.
The total number of components in AssemblyXpert shows up immediately, meaning the value is stored somewhere. How do I get that stored value?
Not sure that there are any other ways to do this. AssemblyXpert may be using some internal cached data to get those values. You can also try the AssemblyDoc::GetComponentCount or this method: SwDMDocument8::GetComponentCount. The last one is Document Manager API which reads the data directly from stream (this may be quicker).