Rereading the two pieces of code I posted in the previous question, it's easier than I thought, but I didn't have time to test.
To be put in a new macro in SolidWorks from the " Macro > New Tools > Tools " menu.
'Edit: code cleanup and comments
Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim vConfNameArr as Variant Dim sConfigName As String Sun i As Long
Set swApp = CreateObject("SldWorks.Application") SolidWorks Enables in VBA Set swModel = swApp.ActiveDoc 'Retrieves the active document vConfNameArr = swModel.GetConfigurationNames 'Retrieves all configurations in an array For i = 0 To UBound(vConfNameArr) Loop across all configurations sConfigName = vConfNameArr(i) sConfigName.ChildComponentDisplayInBOM = swChildComponentInBOMOption_e.swChildComponent_Promote 'Activates the promote function on each of the configurations Next i End Sub
I have a colleague who knows macros, here's what he wrote.
After a test or two, it seems to work.
Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swConfig As SldWorks.Configuration Dim vConfNameArr as Variant Dim sConfigName As String Sun i As Long
Set swApp = Application.SldWorks SolidWorks Enables in VBA Set swModel = swApp.ActiveDoc 'Retrieves the active document vConfNameArr = swModel.GetConfigurationNames 'Retrieves all configurations in an array For i = 0 To UBound(vConfNameArr) Loop across all configurations Set swConfig = swModel.GetConfigurationByName(vConfNameArr(i)) 'sConfigName = vConfNameArr(i) swConfig.ChildComponentDisplayInBOM = swChildComponentInBOMOption_e.swChildComponent_Promote 'Activates the promote function on each of the configurations