BOM and Balloon Macro Issues

Hello All,

I am very new to macros.  I am having problems with a section of my macro code.  At one point, a BOM table is generated from the current view.  I can get it to generate correctly for a PartsOnly and Indented BOM, but the table shows up blank when I try a TopLevelOnly BOM.  See the code below...

Dim AnchorType         As Long

    Dim BomType            As Long

    Dim Configuration      As String

    Dim TableTemplate      As String

    Dim swBOMAnnotation    As SldWorks.BomTableAnnotation

    Dim swBOMFeature       As SldWorks.BomFeature

   

    AnchorType = swBOMConfigurationAnchor_TopLeft

    BomType = swBomType_TopLevelOnly

    TableTemplate = "C:\\Program Files\\SolidWorks Corp\\SolidWorks\\lang\\english\\bom-standard.sldbomtbt"

    Configuration = ""

    Set swBOMAnnotation = swView.InsertBomTable3(False, 0.104293835860446, 0.20955, AnchorType, BomType, Configuration, TableTemplate, False)

    Set swBOMFeature = swBOMAnnotation.BomFeature

I have another issue where I am trying to get it to autoballoon the current view and it seems to miss some of the balloons.  See code below...

Dim boolstatus As Boolean

   

    boolstatus = swModel.ActivateView("Drawing View1")

    boolstatus = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 9.20724224417876E-02, 0.147008710805877, 0, False, 0, Nothing, 0)

   

    Dim vNotes As Variant

    Dim autoballoonParams As Object

   

    Set autoballoonParams = swModel.CreateAutoBalloonOptions()

    autoballoonParams.Layout = 1

    autoballoonParams.ReverseDirection = False

    autoballoonParams.IgnoreMultiple = False

    autoballoonParams.InsertMagneticLine = False

    autoballoonParams.LeaderAttachmentToFaces = False

    autoballoonParams.Style = 1

    autoballoonParams.Size = 2

    autoballoonParams.UpperTextContent = 1

    autoballoonParams.UpperText = """"

    autoballoonParams.Layername = "-None-"

    autoballoonParams.ItemNumberStart = 1

    autoballoonParams.ItemNumberIncrement = 1

    autoballoonParams.ItemOrder = 0

    vNotes = swModel.AutoBalloon5(autoballoonParams)

    swModel.ClearSelection2 True

I'm still learning, so any steps in the right direction will be helpful. Thanks for your help.

SolidworksApi macros