Microsoft KB Archive/157556

= XL97: Problems When Removing Line from Drawing Object =

Article ID: 157556

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q157556





SYMPTOMS
In Microsoft Excel, if you use a Microsoft Visual Basic for Applications macro to remove the border line from a drawing object or AutoShape, one of the following problems may occur:  The interior of the object may change color, switch to a different pattern, or turn completely transparent. -or-

 You may receive the following error message

Run-time error '1004':

Unable to set the LineStyle property of the Border class

and your macro halts.



CAUSE
These problems may occur if you try to use either of the following lines of code to remove the border line from a drawing object, such as a rectangle or an oval: Selection.Border.LineStyle = xlNone

-or-

Selection.Border.LineStyle = xlLineStyleNone



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. In Excel, use the following line of code if you want to remove the border line from a drawing object: Selection.ShapeRange.Line.Visible = msoFalse



MORE INFORMATION
In Excel, you can fill drawing objects such as rectangles, ovals, and freehand objects with a variety of effects, including solid colors, gradient fills, patterns, textures, and pictures.

If you run either of the commands shown above, the commands may not work correctly. The results you get depend on the type of fill applied to the object whose line you are removing:   Fill type     Results Solid Color  The line is removed correctly.

Gradient     You receive the "Run-time error '1004'" error message shown above, and the line is NOT removed.

Pattern      The line is removed correctly, but the pattern may be                 replaced by another, different pattern.

Texture      The line is removed correctly, but the texture fill is                 removed and replaced with a solid white fill.

Picture      The line is removed correctly, but the picture fill is                 removed completely, so that the object is now transparent. To avoid these problems, use the line of code shown in the "Workaround" section whenever you want to remove the border line from a drawing object.

Additional query words: XL97 8.0 Run time error 1004

Keywords: kbbug kbdtacode kberrmsg kbpending kbprogramming KB157556

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.