Help with componets : ExcludeFromBOM method

I've been working on a macro to check status if a componet is excluded from the bill of material.

Working in a drawing selecting a view - getting visible componets then looping, the ExcludeFromBOM method isnt returning the correct value.

Not sure what I'm doing wrong.

Please help and thanks in advance....

'---------------------------------

'

' Preconditions: Drawing document is open and

'                 contains at least one component.

'                 drawing view name: "Drawing View13"

'

' Postconditions: None

'

'----------------------------------

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim swSelMgr As SldWorks.SelectionMgr

Dim swSelData As SldWorks.SelectData

Dim swComp As SldWorks.Component2

Dim swView As SldWorks.View

Dim swEnt As SldWorks.Entity

Dim vComps As Variant

Dim vEdges As Variant

Dim itr As Long

Dim boolstatus As Boolean

Dim ChildCount As Integer

Dim i          As Integer

Dim viewname As String


Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swModelDocExt = swModel.Extension

Set swSelMgr = swModel.SelectionManager


viewname = "Drawing View13"


boolstatus = swModel.ActivateView(viewname)

boolstatus = swModelDocExt.SelectByID2(viewname, "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

Set swView = swSelMgr.GetSelectedObject5(1)

swModel.ClearSelection2 True

'Get all visible components

vComps = swView.GetVisibleComponents

ChildCount = UBound(vComps)

For i = 0 To ChildCount

'Print name of first visible component

Debug.Print vComps(i).Name2

Debug.Print vComps(i).ExcludeFromBOM

Next i

SolidworksApi macros