Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am creating and using Excel.Style objects and I'm running into problems
with accessing the Borders of an Excel.Style object. 1. The enumerator to access the Top Border "Excel.xlBorderTop" returns the Left Border object. It seems that the enumerators when access the Borders Collection in the style does not match correctly. WHY? and What can I do to rectify the situation? 2. I was finally able to gain access to the TOP border, however the LINE CODE and the WEIGHT of the border was incorrect. WHY? Is there any reason that the Excel.Style object should contain the formatting information different from the Excel.Range object???? Both contain the various formatting options like FONT, ALIGNMENT, PATTERN etc. But for some reason accessing the BORDER information from the Excel.STYLE object produces erroneous behavior... Thanks for the help |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The borders collection is slightly different with Style & CF formats as,
unlike the range object which may have to contend with 'outside' & 'inside' borders, these are effectively a single cell. Have a go with this - Sub test2() Dim sty As Style Dim bdrs As Border On Error Resume Next Set sty = ActiveWorkbook.Styles("TestStyle") If sty Is Nothing Then Set sty = ActiveWorkbook.Styles.Add("TestStyle") End If On Error GoTo 0 With sty.Borders '.Item(xlLeft).Weight = xlContinuous .Item(xlLeft).ColorIndex = 3 .Item(xlTop).LineStyle = xlContinuous .Item(xlTop).ColorIndex = 4 .Item(xlRight).LineStyle = xlContinuous .Item(xlRight).ColorIndex = 5 .Item(xlBottom).LineStyle = xlContinuous .Item(xlBottom).ColorIndex = 6 End With With Range("C3") .Style = "TestStyle" With .Borders Debug.Print .Item(xlEdgeLeft).ColorIndex ' 3 Debug.Print .Item(xlEdgeTop).ColorIndex '4 Debug.Print .Item(xlEdgeRight).ColorIndex ' 5 Debug.Print .Item(xlEdgeBottom).ColorIndex ' 6 End With End With ' sty.Delete ' << End Sub Regards, Peter T "snoriidr" wrote in message ... I am creating and using Excel.Style objects and I'm running into problems with accessing the Borders of an Excel.Style object. 1. The enumerator to access the Top Border "Excel.xlBorderTop" returns the Left Border object. It seems that the enumerators when access the Borders Collection in the style does not match correctly. WHY? and What can I do to rectify the situation? 2. I was finally able to gain access to the TOP border, however the LINE CODE and the WEIGHT of the border was incorrect. WHY? Is there any reason that the Excel.Style object should contain the formatting information different from the Excel.Range object???? Both contain the various formatting options like FONT, ALIGNMENT, PATTERN etc. But for some reason accessing the BORDER information from the Excel.STYLE object produces erroneous behavior... Thanks for the help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
border colors and style | Excel Discussion (Misc queries) | |||
Change border style using VB | Excel Discussion (Misc queries) | |||
Create new border style? | Excel Discussion (Misc queries) | |||
Excel 2003 List does not preserve border style for all rows | Excel Discussion (Misc queries) | |||
Border style of Excel forms | Excel Programming |