4 Replies Latest reply on May 8, 2014 3:44 PM by Danny Bradford

    Strange Macro problem hiding a row in a Drawing BOM Table

    Danny Bradford

      Greetings,

       

      Have created a Macro to create 10 rows above the selected rows (Thanks mostly to this forum therefore thanks to many of you!) and I would like for those same row to be hidden.

       

      In fact I shed the insert portion and am simply trying to hide a row in a BOM table. Code is below. The result (Solidworks 2013) is the system creates a phantom row and hides it. I know it is phantom because when I try to show the row it simply disappears. Quite strange!

       

      The code below has more than required because I just wanted to one "RowHidden" line of code to work. All the other stuff is to complete teh overall macro once this works. You can see that I am trying to simply hide the 3rd row.

       

      Option Explicit

      Dim swApp As SldWorks.SldWorks

      Sub main()

          Dim swModel                 As SldWorks.ModelDoc2

          Dim swSelectionMgr          As SldWorks.SelectionMgr

          Dim swDrawing               As SldWorks.DrawingDoc

          Dim swAnnotation            As SldWorks.Annotation

          Dim swTableAnnotation       As SldWorks.BomTableAnnotation

          Dim firstRow                As Long

          Dim lastRow                 As Long

          Dim firstColumn             As Long

          Dim lastColumn              As Long

          Dim Do_It                   As Boolean

          Dim Hide_It                 As Boolean

          Dim i                       As Integer

          Dim m                       As Integer

          Dim InsertRow               As Integer

          Dim HideRow                 As Long

         

       

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swSelectionMgr = swModel.SelectionManager

          Set swDrawing = swModel

         

          Set swTableAnnotation = swSelectionMgr.GetSelectedObject6(swSelectionMgr.GetSelectedObjectCount2(-1), -1)

          Set swAnnotation = swTableAnnotation.GetAnnotation

          swTableAnnotation.GetCellRange firstRow, lastRow, firstColumn, lastColumn

             

          'MsgBox "First selected cell's row     = " & firstRow

          'MsgBox "Last selected cell's row      = " & lastRow

          'MsgBox "First selected cell's column  = " & firstColumn

          'MsgBox "Last selected cell's column   = " & lastColumn

         

          For m = 0 To 0

            HideRow = CLng(firstRow + m)

            MsgBox "Row Hide placement  =" & HideRow

            'MsgBox "First Row  =" & firstRow

            swTableAnnotation.RowHidden(3) = True

          Next m

       

       

      End Sub

       

       

      Any help is greatly appreciated!!

       

      Danny Bradford