Option Explicit
Const swCustomInfoText = 30
Const swCustomInfoNumber = 3
Sub CodeSamples()
Dim swApp As Object
Dim Part As Object
Dim sConfig As String
Dim s1 As String, s2 As String
Set swApp = GetObject(, "SldWorks.Application")
Set Part = swApp.ActiveDoc
'Define the Configuration
' -Use the name of the config if not default
' -You can get a list of all configs using:
' Part.GetConfigurationCount
' Part.GetConfigurationNames
sConfig = "" 'Default Config
'Get Current Value of Property
s1 = Part.CustomInfo2(sConfig, "RevNo")
If Len(s1) = 0 Then
MsgBox "RevNo is Not Set or Not Defined"
Else
MsgBox "RevNo: " & s1
End If
'Store the Custom Property
' AddCustomInfo3 returns True if Added
' if False, the property already exists
' In that case, just update the value
s2 = "2" 'Define RevNo
If Part.AddCustomInfo3(sConfig, "RevNo", swCustomInfoText, s2) = False Then
Part.CustomInfo2(sConfig, "RevNo") = s2
End If
Set Part = Nothing
Set swApp = Nothing
End Sub