Leonis Wong

Create multi-line custom property with macro

Discussion created by Leonis Wong on Dec 28, 2018
Latest reply on Dec 29, 2018 by Deepak Gupta



Just to share this simple macro codes for those users who need to create multi-line description in custom property tab.

What it does is that it will create 4 empty lines in your description tab,

Then you can proceed to enter your description and click apply.

I have modified the code to also include original description value if there's any so as not to overwrite it accidentally.


Sub main()


Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swModelDocExt = swModel.Extension


'Get Full Path to active file

Dim Filename As String

   Filename = swModel.GetPathName

   Debug.Print Filename


'Get active configuration name

Dim configName As String

   configName = swApp.GetActiveConfigurationName(Filename)

   Debug.Print configName


'Point to customer property object

Set swCustProp = swModelDocExt.CustomPropertyManager(configName)


'Create multi-line format description

Dim newDesc As String

  newDesc = swCustProp.Get("Description") & vbLf & _

                     "" & vbLf & _

                     "" & vbLf & _



'Copy custom property to Description

swCustProp.Add3 "Description", 30, newDesc, 1



Dim bRetValue As Boolean

  bRetValue = swModel.ForceRebuild3(True)


End Sub