need macro help

Programming and macros
mraycii
Posts: 6
Joined: Tue Mar 28, 2023 3:02 pm
Answers: 0
x 3
x 2

need macro help

Unread post 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.
by zwei » Thu Mar 30, 2023 12:51 am
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
Go to full post
User avatar
SPerman
Posts: 1819
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 13
x 2003
x 1677
Contact:

Re: need macro help

Unread post 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
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
zwei
Posts: 700
Joined: Mon Mar 15, 2021 9:17 pm
Answers: 18
Location: Malaysia
x 185
x 597

Re: need macro help

Unread post 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
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
mraycii
Posts: 6
Joined: Tue Mar 28, 2023 3:02 pm
Answers: 0
x 3
x 2

Re: need macro help

Unread post by mraycii »

Zhen-Wei Tee wrote: Thu Mar 30, 2023 12:51 am
Outstanding! It worked wonderfully. Thanks very much for your help.
Post Reply