Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel.Style object: Border problems

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel.Style object: Border problems

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
border colors and style ralf Excel Discussion (Misc queries) 7 January 17th 10 04:36 PM
Change border style using VB Dbl_Planker Excel Discussion (Misc queries) 0 September 24th 09 10:18 PM
Create new border style? alexmoss Excel Discussion (Misc queries) 6 February 9th 09 03:18 AM
Excel 2003 List does not preserve border style for all rows Geetha Excel Discussion (Misc queries) 0 August 16th 06 07:22 PM
Border style of Excel forms Shu Excel Programming 3 April 29th 04 12:33 PM


All times are GMT +1. The time now is 11:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"