LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Border Mystery?

I have code that copies border formatting from one cell to a range. Its
been working fine. But I'm now getting a runtime error "Unable to set the
Weight property of the Border class" trying to copy an xlInsideVertical
border. The same error occurs trying to copy the LineStyle property.

I know that a common problem with the xlInsideVertical border is that it can
only be applied to a multi-column range. My code checks for this condition.
However in this case, the target range is B20:E20.

I went back and retested this code under XL97, XL2000, XL2002 and XL2003
(all versions include all of the latest MS updates). It works under XL97
but fails under all of the later releases.

If I manually open the workbook under XL97 and then examine the source
cell's border in a watch window it has a LineStyle of 11 and a Weight
of -4138 (this is the case where the copy works). If I repeat this
procedure under XL2003, LineStyle is 241 and Weight is 225!

I presume this difference is what's causing it to work under XL97 and fail
under later versions.

I've looked at all of the LineStyle constants and neither 11 or 241 is
defined! I don't know what to make of that?

Here's the code in question:

Private Sub CopyBorder(borderType As Integer, Target As Range, source As
Range)
Dim TargetBorder As Border
Dim SourceBorder As Border

If Not (borderType = xlInsideHorizontal And Target.Rows.Count < 2 Or _
borderType = xlInsideVertical And Target.Columns.Count < 2)
Then
Set TargetBorder = Target.Borders(borderType)
Set SourceBorder = source.Borders(borderType)

TargetBorder.Weight = SourceBorder.Weight
TargetBorder.LineStyle = SourceBorder.LineStyle
TargetBorder.color = SourceBorder.color
TargetBorder.ColorIndex = SourceBorder.ColorIndex
End If
End Sub

Again, its the assignment of Weight and LineStyle that fail. The assignment
of Color and ColorIndex work fine.

Any thoughts?

TIA,

josh


 
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
Row Header Mystery Karen Excel Discussion (Misc queries) 10 December 8th 09 06:57 PM
border on last cell of page effects border on beginning cell of ne GaryE Excel Discussion (Misc queries) 0 March 23rd 09 05:47 AM
One of lifes little mystery? JethroUK© Excel Worksheet Functions 21 October 11th 06 11:12 PM
MYSTERY!! WhytheQ Excel Discussion (Misc queries) 2 June 20th 06 11:00 AM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM


All times are GMT +1. The time now is 07:21 AM.

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

About Us

"It's about Microsoft Excel"