MikeJarosz
2007-02-09, 08:59 PM
I am creating a drawing index as an Acad table in 2005. I need to put headers in for Civil, Architectural, structural etc. I want the header to be two merged rows and appear anywhere up and down the table as needed, so I can't use the header row type. Merged cells will work much better for me. My problem is when I merge two cells 8mm high, the merged cell is 18.66667, not the 16.0000 I expected. I thought that the vertical cell margin was the cause of the discrepancy, but making it zero didn't help. Then I thought maybe the cell outline line thickness did it. Nope.
I tried explicitly resetting the row height to 16 after the merge, but still got 18.66667. That number is suspicious: is there some other "invisible" factor affecting the row height of two merged cells?
I want the rows to remain modular so they line up across the page when I need multiple tables.
(the numbers are all in millimeters)
Dim Pspace As AcadPaperSpace
Dim DwgIndex As AcadTable
Dim TemplateFileName As String
Dim Entity As AcadEntity
Dim CurrentRow As Long
'load template drawing
TemplateFileName = "t:testDwgIndex.dwt"
Documents.Add TemplateFileName
Set Pspace = ThisDrawing.PaperSpace
'note: this code will grab the first table it finds!
For Each Entity In ThisDrawing.PaperSpace
If TypeOf Entity Is AcadTable Then
Set DwgIndex = Entity
Exit For
End If
Next Entity
DwgIndex.RecomputeTableBlock False
'rows and cols are zero based
CurrentRow = 4
With DwgIndex
'make 1st header
.MergeCells CurrentRow, (CurrentRow + 1), 0, 2
Debug.Print .GetRowHeight(CurrentRow)
'.SetRowHeight CurrentRow, 16
.SetCellAlignment CurrentRow, 0, acMiddleCenter
.SetCellTextStyle CurrentRow, 0, "titles"
.SetCellTextHeight CurrentRow, 0, 8
.SetText CurrentRow, 0, "HEADER"
CurrentRow = CurrentRow + 2
End With
The debug.print rowheight returns 18.00000001, even though the cells have already been merged.
I would not have used the for...next loop if I could find a better way to grab a table. Apparently there is no AcadTables collection with an Item() property.
I tried explicitly resetting the row height to 16 after the merge, but still got 18.66667. That number is suspicious: is there some other "invisible" factor affecting the row height of two merged cells?
I want the rows to remain modular so they line up across the page when I need multiple tables.
(the numbers are all in millimeters)
Dim Pspace As AcadPaperSpace
Dim DwgIndex As AcadTable
Dim TemplateFileName As String
Dim Entity As AcadEntity
Dim CurrentRow As Long
'load template drawing
TemplateFileName = "t:testDwgIndex.dwt"
Documents.Add TemplateFileName
Set Pspace = ThisDrawing.PaperSpace
'note: this code will grab the first table it finds!
For Each Entity In ThisDrawing.PaperSpace
If TypeOf Entity Is AcadTable Then
Set DwgIndex = Entity
Exit For
End If
Next Entity
DwgIndex.RecomputeTableBlock False
'rows and cols are zero based
CurrentRow = 4
With DwgIndex
'make 1st header
.MergeCells CurrentRow, (CurrentRow + 1), 0, 2
Debug.Print .GetRowHeight(CurrentRow)
'.SetRowHeight CurrentRow, 16
.SetCellAlignment CurrentRow, 0, acMiddleCenter
.SetCellTextStyle CurrentRow, 0, "titles"
.SetCellTextHeight CurrentRow, 0, 8
.SetText CurrentRow, 0, "HEADER"
CurrentRow = CurrentRow + 2
End With
The debug.print rowheight returns 18.00000001, even though the cells have already been merged.
I would not have used the for...next loop if I could find a better way to grab a table. Apparently there is no AcadTables collection with an Item() property.