LineStyle Property Problem

LEXCERM

Registered User.
Local time
Today, 18:30
Joined
Apr 12, 2004
Messages
169
Hi All,

I am experiencing the following error when trying to execute this snippet of code:-
Run-Time Error 1004: Unable to set the LineStyle property of the Border class


Code:
[B]appXL.Selection.Borders(xlEdgeTop).LineStyle = xlContinuous[/B]
appXL.Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
appXL.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
appXL.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
appXL.Selection.Borders(xlEdgeBottom).LineStyle = xlNone
appXL.Selection.Borders(xlEdgeRight).LineStyle = xlNone
appXL.Selection.Borders(xlInsideVertical).LineStyle = xlNone
appXL.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

It errors at the highlighted line above (xlEdgeTop).

I have tried numerouse things, but cannot figure it out. Have used this with With statements, moved the offending statement up and down the code, but to no avail.

The Excel cell I am trying to format is in the centre of the spreadsheet. ALl the other borders are fine, but this one doesn't want to know!

Thanks in advance,
Paul.
 
Check if the cell is protected as that would give you this error message

Peter
 
Hi Peter,

Sorry for the delay in replying. I've got it to work now.

The code I posted was added just after a pivot table had been created and the particular cell I was trying to format already had certain elements of the cell bordered - so there may have been some sort of conflict when trying to re-format the cell. Therefore, I firstly set all the borders to NONE, then re-applied my formatting ... and it worked! :)

Best rgds,
Paul.
 

Users who are viewing this thread

Back
Top Bottom