Page 1 of 1

need macro help

Posted: Wed Mar 29, 2023 12:05 pm
by mraycii
I'm a total noob at writing code.

I'm trying to write a macro which will do the following:

1.) ensure the check is "on" next to "Show Configuration Names" under Tree Display in the Configuration tab
2.) ensure the check is "on" next to "Show Configuration Descriptions" under Tree Display in the Configuration tab
3.) ensure the check is "on" next to "Numeric" under Tree Order in the Configuration tab

This area is accessed by navigating to the configurations tab in a .sldprt file, then right clicking on the header at the top of the list of configurations.
image.png

Here is the code I've written so far (it will turn on the configuration name and configuration description). I just can't get the "Numeric" turned on under Tree Order.
image.png

Any help you could provide would be greatly appreciated.

Re: need macro help

Posted: Wed Mar 29, 2023 2:42 pm
by SPerman
Does this do what you want? I am on 2022, so I don't have the same options you show.

https://help.solidworks.com/2021/englis ... ple_VB.htm

Re: need macro help

Posted: Thu Mar 30, 2023 12:51 am
by zwei
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Model As ModelDoc2
Dim ConfigMgr As ConfigurationManager
Dim v As Variant
Dim i As Long

Sub main()

Set swApp = Application.SldWorks
Set Model = swApp.ActiveDoc
Set ConfigMgr = Model.ConfigurationManager

ConfigMgr.ShowConfigurationDescriptions = True
ConfigMgr.ShowConfigurationNames = True
ConfigMgr.SortConfigurationTree swSortType_Numeric

End Sub

Re: need macro help

Posted: Tue Apr 04, 2023 11:30 am
by mraycii
Zhen-Wei Tee wrote: Thu Mar 30, 2023 12:51 am
Outstanding! It worked wonderfully. Thanks very much for your help.