Changing the Font of schedule headers with SetCellStyle

Changing the Font of schedule headers with SetCellStyle

Rockit_for_Revit
Advocate Advocate
1,212 Views
1 Reply
Message 1 of 2

Changing the Font of schedule headers with SetCellStyle

Rockit_for_Revit
Advocate
Advocate

Hello,

I have project with hundreds of schedules created with the rows in the headers.

I would like to use the following code to change the font of each of the cells in the headers.

 

For intHeaderRow As Integer = 0 To intScheduleRowColumnCountHeaderRows
    For intHeaderColumn As Integer = 0 To intScheduleRowColumnCountHeaderColumns
        Dim objTableCellStyle As TableCellStyle = objTableSectionData.GetTableCellStyle(intHeaderRow, intHeaderColumn)
        If Not objTableCellStyle.FontName.Equals(strNewFontName) Then
                                        If objTableSectionData.AllowOverrideCellStyle(intHeaderRow, intHeaderColumn) Then
                                            Dim options As TableCellStyleOverrideOptions = New TableCellStyleOverrideOptions With {
                                                .FontSize = False
                                            }
                                            objTableCellStyle.FontName = strNewFontName
                                            objTableCellStyle.SetCellStyleOverrideOptions(options)
                                            objTableSectionData.SetCellStyle(intHeaderRow, intHeaderColumn, objTableCellStyle)
            End If
        End If
    Next
Next

This code works well & changes the font, however it does not preserve the size or the boldness of the cell.

The size gets changed to the same as what is set in the schedule appearance header text.

Any ideas?

Kind Regards

David

 

0 Likes
Accepted solutions (1)
1,213 Views
1 Reply
Reply (1)
Message 2 of 2

david_rock
Enthusiast
Enthusiast
Accepted solution

Sorry for the multiple post, site connection issues.

I have solved this now by removing the options.

For intHeaderRow As Integer = 0 To intScheduleRowColumnCountHeaderRows
                                For intHeaderColumn As Integer = 0 To intScheduleRowColumnCountHeaderColumns
                                    Dim objTableCellStyle As TableCellStyle = objTableSectionData.GetTableCellStyle(intHeaderRow, intHeaderColumn)
                                    If Not objTableCellStyle.FontName.Equals(strNewFontName) Then
                                        If objTableSectionData.AllowOverrideCellStyle(intHeaderRow, intHeaderColumn) Then
                                            objTableCellStyle.FontName = strNewFontName
                                            objTableSectionData.SetCellStyle(intHeaderRow, intHeaderColumn, objTableCellStyle)
                                        End If
                                    End If
                                Next
                            Next

Kind Regards

David

 

0 Likes