AnsweredAssumed Answered

Move folders in VBA

Question asked by Sébastien Denis on Nov 13, 2020
Latest reply on Nov 16, 2020 by Sébastien Denis

In one of my macros, I would like to rearrange the folders in the tree structure.
I would like to move the "Screws" folder to the very end of the tree, and the "FI" folder just above the "Screws" folder.


Only if the folders have parts or assemblies between them as on the pictures the moved folders are not placed at the end.
Do you have an idea how to move these folders as desired?


Enclosed you will find the code and an example of how to assemble them.

Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim modelDocExt As SldWorks.ModelDocExtension
Dim bRet As Boolean

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swAssy = swModel

Set modelDocExt = swAssy.Extension
bRet = modelDocExt.ReorderFeature("FI", "", swMoveToEnd)
bRet = modelDocExt.ReorderFeature("Visserie", "", swMoveToEnd)

End Sub