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
SolidworksApi macros
Change: Dim swTableAnnotation As SldWorks.BomTableAnnotation
To: Dim swTableAnnotation As SldWorks.TableAnnotation
Well, actually that is how I had it for the majority of my tests. I only added "Bom" on the last test in fact and I forgot it was there. Both options do the same thing.
Thanks for the response!
You mention that you are wanting to hide the third row, but you are actually trying to hide the fourth row (the row numbers start at Zero). Does your table have four rows?
Yes it has plenty of rows. If it would hide any of my realy rows I could work with that. The problem is that it places some virtual row in hide mode that does not really exist.
I have used a variable to define the row number and hard numbers and they all do this same thing.