AnsweredAssumed Answered

How do I make a VBA script write to a file custom property?

Question asked by Mike Bosscher on Dec 1, 2016
Latest reply on Dec 2, 2016 by Mike Bosscher

I'm trying to write a custom property that represents whether a file passed or failed a design checker task. I'd then be able to use this custom property to make a decision on whether to run the convert task and release the document, or reject it and send the user a notification.

I'm trying to write the custom property at the file level, but so far I can only seem to write it to a configuration specific custom property (I'm relatively new at this whole macro thing....).

Rather than get to involved in the whole design checker concept, I wanted to isolate this issue for the purpose of trouble shooting, so I put together a short macro whose only purpose was to write a custom property. Here's what I've got so far;

 

'---------------------------------------------------------------------------
' Preconditions:
' 1. Open a part document.
'
' Postconditions:
' 1. Adds a date custom property to the part's configuration.
'---------------------------------------------------------------------------

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim config As SldWorks.Configuration
Dim cusPropMgr As Object
Dim lRetVal As Long
Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set config = swModel.GetActiveConfiguration
Set cusPropMgr = config.CustomPropertyManager

 

lRetVal = cusPropMgr.Add3("DesignChecker", swCustomInfoType_e.swCustomInfoText, "Failed", swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd)

 

End Sub

'--------------------------------------------------------------------------------

 

Any ideas? I'm sure it's relatively simple, but my brain's just not cooperating at the moment..

 

Thanks,

Mike.

Outcomes