robertb_NZ
Well-known member
I am writing a VB.NET application that processes an Excel spreadsheet. As each line is processed it is highlighted, and there is an option to step through the lines. I have a method to highlight the current line: -
Highlight and Normal are simply colors defined in global definitions: -
This works perfectly, but why do I need the statement
My code is working, but I'm puzzled about this inconsistency. What don't I understand?
BTW moderator: what forum should we post VB Interop questions into? Is MS Office Automation considered a "Third Party"?
Sub HighlightThisRow(Row As Integer)
' Current row is highlighted. Line above is un-highlighted, unless = DataRow
Dim Cell1 As String = Cell(Row, 1)
Dim Cell2 As String = Cell(Row, LastUsedColumn)
Dim xlRow As Excel.Range = xlWorkSheet.Range(Cell1, Cell2)
xlRow.Interior.Color = Highlight
xlRow.Borders.Color = Color.LightGray
If Row <> FirstDataRow Then
End SubDim Cell1 As String = Cell(Row, 1)
Dim Cell2 As String = Cell(Row, LastUsedColumn)
Dim xlRow As Excel.Range = xlWorkSheet.Range(Cell1, Cell2)
xlRow.Interior.Color = Highlight
xlRow.Borders.Color = Color.LightGray
If Row <> FirstDataRow Then
Cell1 = Cell(Row - 1, 1)
Cell2 = Cell(Row - 1, LastUsedColumn)
Dim xlRange As Excel.Range = xlWorkSheet.Range(Cell1, Cell2)
xlRange.Interior.Color = Normal
End IfCell2 = Cell(Row - 1, LastUsedColumn)
Dim xlRange As Excel.Range = xlWorkSheet.Range(Cell1, Cell2)
xlRange.Interior.Color = Normal
Highlight and Normal are simply colors defined in global definitions: -
Dim Highlight As Color = Color.LightCyan
Dim Normal As Color = Color.White
Dim Normal As Color = Color.White
This works perfectly, but why do I need the statement
xlRow.Borders.Color = Color.LightGray
Without this the statement
xlRow.Interior.Color = Highlight
causes the cell borders to be list. However this is not the case withxlRange.Interior.Color = Normal
which leaves them unchanged.My code is working, but I'm puzzled about this inconsistency. What don't I understand?
BTW moderator: what forum should we post VB Interop questions into? Is MS Office Automation considered a "Third Party"?