XL97: Problems When Removing Line from Drawing Object

Last reviewed: March 13, 1998
Article ID: Q157556
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

In Microsoft Excel 97, if you use a 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 examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

In Microsoft Excel 97, use the following line of code if you want to remove the border line from a drawing object:

   Selection.ShapeRange.Line.Visible = msoFalse

STATUS

This behavior is by design of Microsoft Excel 97.

MORE INFORMATION

In Microsoft Excel 97, drawing objects such as rectangles, ovals, and freehand objects can be filled 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 is being removed as follows:

   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
Keywords : kbcode kberrmsg kbprg xlvbahowto xldraw
Version : WINDOWS:97
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.