I have an embedded spreadsheet in a solidworks drawing that reads a custom property.
I use the Custom Properties Tab to allow users to enter "Description", "Units", and "type" from dropdown lists.
(Note: There is logic in the embedded excel spreadsheet that will assign a different tolerance and display based on the dropdown selections. A general table is not capable of providing this level of logic (a simple look up table) and since the drawing is a template, I cannot use a design table.)
If I change andy of the custom properties for "description", "Units", or "type", the only way for it to update is to save the SW drawing, close it, and reopen it.
Is there a way to update the excel spreadsheet automatically when you change the custom property?
Another user provide me with the code to add the SW custom property to the excel spreadsheet. It works, but it doesn't seem to work "on-the-fly"
Private Sub Workbook_Open()
UpdateCells
End Sub
' We need to call this whenever SW updates a custom property
Sub UpdateCells()
Dim swApp As SldWorks.SldWorks
Set swApp = New SldWorks.SldWorks
Dim swModel As ModelDoc2: Set swModel = swApp.ActiveDoc
' Gets the custom property description and puts it into the A1 cell
Workbooks(1).Worksheets(1).Range("A1").Value = swModel.CustomInfo2("", "Description")
Workbooks(1).Worksheets(1).Range("A2").Value = swModel.CustomInfo2("", "Units")
Workbooks(1).Worksheets(1).Range("A3").Value = swModel.CustomInfo2("", "type")
End Sub
I would greatly appreciate anyone who can come up with a clever solution to my dilemna.
thanks,
SolidworksApi macros