Here is one example of how you could do it. Although, you might have to do some extra checking in the case if a drawing had more than one BOM on a sheet.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim sBOMName As String
Set swApp = Application.SldWorks
If swApp.GetDocumentCount() = 0 Then Exit Sub
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Or swModel.GetType <> swDocumentTypes_e.swDocDRAWING Then
MsgBox ("You Must Run This Macro Inside A Drawing")
sBOMName = ""
Set swFeat = swModel.FirstFeature
Do While Not swFeat Is Nothing
If (swFeat.GetTypeName = "BomFeat") Then
sBOMName = swFeat.Name
Set swFeat = swFeat.GetNextFeature
If sBOMName = "" Then
Debug.Print ("There Was No BOM Found On This Sheet")
Debug.Print ("The Name Of The BOM Is: " + sBOMName)
Thanks for the quick response. I tried to use the code you gave me but I keep running into the same issue as with some other ways I tried. I keep getting "Compile Error: Can't Find Project or Library" for swFeat. What do you think might be causing this error?
Sounds like a reference error for the macro. Try this, open your macro, copy all the text and paste into notepad. Then close your macro, start a recording of a new macro, stop recording, save it with the same name in a different location. Then go to edit that macro and paste the code from your previous macro into it. See if that solves your references issue. Also, what version of Solidworks are you using?
BINGO... You are the man!! I've got it to work now. Thanks for your help. oh and I am using 2015!!
No problem. Glad to help.