Is there a macro or set of macros that could be combined that could:
- Hide all tables in a drawing on all sheets;
- Show tables having specific names on the first sheet of a drawing, i.e. these three tables "BOM Table" "Revision Table" "TB" (no quotes).
- Sheet1 may not be named Sheet1.
Based on how I've seen other macros work, I would think it easier to hide all tables before showing specific tables, but that is a presumption on my part, not a requirement.
I have no ability to write a macro, so any and all assistance is greatly appreciated !!!
SWx 2017 SP3.0; WIndows 7 and 10
Here you go
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swAnn As SldWorks.Annotation
Dim swTableAnn As SldWorks.TableAnnotation
Dim vSheetNames As Variant
Dim swTables As Variant
Dim swTable As Variant
Dim i As Integer
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
vSheetNames = swDraw.GetSheetNames
For i = UBound(vSheetNames) To 0 Step -1
boolstatus = swDraw.ActivateSheet(vSheetNames(i))
Set swView = swDraw.GetFirstView
If swView.GetTableAnnotationCount <> 0 Then
swTables = swView.GetTableAnnotations
For Each swTable In swTables
Set swTableAnn = swTable
Set swAnn = swTableAnn.GetAnnotation
'Debug.Print swTableAnn.Title
If i <> 0 Or (i = 0 And (swTableAnn.Title <> "BOM Table" And swTableAnn.Title <> "Revision Table" And swTableAnn.Title <> "TB")) Then
swAnn.Visible = swAnnotationVisibilityState_e.swAnnotationHidden
Debug.Print "Hide " & swTableAnn.Title
Else
swAnn.Visible = swAnnotationVisibilityState_e.swAnnotationVisible
Debug.Print "Show " & swTableAnn.Title
End If
Debug.Print
Next
End If
Next
swDraw.ClearSelection2 True
End Sub