I am attempting to create a macro that will set all the views on a drawing page, to be connected to the default BOM by checking the “Link balloon test to specified table”. This is needed because SW is quite inconsistent in what settings you can apply to multiple views at once.
I have a routine that will select all the views on a page.
---
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDraw As SldWorks.DrawingDoc Dim swSheet As SldWorks.Sheet Dim swView As SldWorks.View Dim vViews As Variant Dim i As Integer Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDraw = swModel Set swSheet = swDraw.GetCurrentSheet vViews = swSheet.GetViews swModel.ClearSelection2 False For i = 0 To UBound(vViews) Set swView = vViews(i) swModel.Extension.SelectByID2 swView.Name, "DRAWINGVIEW", 0, 0, 0, True, 0, Nothing, 0 Next i End Sub
---
The above routine works well. I recorded a macro while I checked the box on just one view, in hopes it would give me the process to do this, so I could just copy it into the routine that selects my views. But, I can’t discern anything in the recorded code that does this, and the macro doesn’t seem to work anyway. Perhaps that setting is not available in VBA.
---
Below is the code that isn’t working.
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.ActivateView("Drawing View20")
boolstatus = Part.Extension.SelectByID2("Drawing View20", "DRAWINGVIEW", 9.60657716227356E-02, 8.64149911426827E-02, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Drawing View20", "DRAWINGVIEW", 9.60657716227356E-02, 8.64149911426827E-02, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
End Sub---
Any suggestions about how to get VBA to set that checkbox in the view properties? (screen grab attached)
