Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature
Dim swBomFeat As SldWorks.BomFeature
Dim vBOMTableAnns As Variant
Dim swBomTableAnn As SldWorks.BomTableAnnotation
Dim swTableAnn As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swFeat = swModel.FirstFeature
Do While Not swFeat Is Nothing
If swFeat.GetTypeName2 = "TableFolder" Then
Set swSubFeat = swFeat.GetFirstSubFeature
Set swBomFeat = swSubFeat.GetSpecificFeature2
vBOMTableAnns = swBomFeat.GetTableAnnotations
Set swBomTableAnn = vBOMTableAnns(0) 'assume only one BOM table
Set swTableAnn = swBomTableAnn
Set swAnn = swTableAnn.GetAnnotation
swAnn.Select3 False, Nothing
Set swFeat = swFeat.GetNextFeature
Also, some macro writing advice:
1. Use "Set swApp = Application.SldWorks" instead of "Set swApp = CreateObject("SldWorks.Application")". The latter is archaic and I have seen issues with macros not running until it is changed to the former.
2. Instead of declaring SolidWorks objects as Object, declare them according to their specific object interface. For example, "Dim swModel As SldWorks.ModelDoc2". This allows for you to use Microsoft Intellisense when writing code and will make your life a lot easier. If you want to see a video tutorial that demonstrates early binding and much more, check out Lesson 2.2 here.
I hope this is helpful!
Thanks Keith! That worked perfectly!
1. Yes, I know - however, we have these macros running on a variety of computers, and we've had issues with both instances. I'm in the process of changing these bit by bit as new updates are being added. The macro I'm writing this for is in a larger SW program that's over 8 or 10 years old! It's a HUGE program too.
2. I am DEFINITELY going to check this out. Thank you!
BTW - I gave you and CadSharp a big plug at our last meeting and gave the CD's away to some people who will definitely benefit from them. Thank you for your support!
Glad to hear this worked. Thanks for your SWUGN feedback--really appreciate it!