Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Can't get border on shape to deselect

Greetings!

I have the following macro which adds a line to an existing oval shape. The
macro works fine, except the shape is still selected when the macro
finishes. I've tried inserting "ActiveSheet.Shapes("Oval 1").Deselect" at
the end of the code, but I get a "runtime error 438." Is there a way I can
get the macro to leave the shape in unselected mode when it finishes?

Thanks,

Jeff

Sub addborder1()
ActiveSheet.Shapes("Oval 1").Select
Selection.ShapeRange.Line.Weight = 8#
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.SchemeColor = 8
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Can't get border on shape to deselect

You should be able to select a cell to get off the Oval--
at the bottom of your code: ActiveCell.Activate

But maybe better is to not select the oval to manipulate it:

Option Explicit
Sub addborder1A()
With ActiveSheet.Shapes("Oval 1").Line
.Weight = 8#
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.SchemeColor = 8
.BackColor.RGB = RGB(255, 255, 255)
End With
End Sub


Jeff Wright wrote:

Greetings!

I have the following macro which adds a line to an existing oval shape. The
macro works fine, except the shape is still selected when the macro
finishes. I've tried inserting "ActiveSheet.Shapes("Oval 1").Deselect" at
the end of the code, but I get a "runtime error 438." Is there a way I can
get the macro to leave the shape in unselected mode when it finishes?

Thanks,

Jeff

Sub addborder1()
ActiveSheet.Shapes("Oval 1").Select
Selection.ShapeRange.Line.Weight = 8#
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.SchemeColor = 8
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
End Sub


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Can't get border on shape to deselect

Dave, thanks! This now works the way I want it to. I keep forgetting (as I
continue to learn VBA) that you don't necessarily have to select an object
in order to work with it.

Thanks again,

Jeff

"Dave Peterson" wrote in message
...
You should be able to select a cell to get off the Oval--
at the bottom of your code: ActiveCell.Activate

But maybe better is to not select the oval to manipulate it:

Option Explicit
Sub addborder1A()
With ActiveSheet.Shapes("Oval 1").Line
.Weight = 8#
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.SchemeColor = 8
.BackColor.RGB = RGB(255, 255, 255)
End With
End Sub


Jeff Wright wrote:

Greetings!

I have the following macro which adds a line to an existing oval shape.
The
macro works fine, except the shape is still selected when the macro
finishes. I've tried inserting "ActiveSheet.Shapes("Oval 1").Deselect" at
the end of the code, but I get a "runtime error 438." Is there a way I
can
get the macro to leave the shape in unselected mode when it finishes?

Thanks,

Jeff

Sub addborder1()
ActiveSheet.Shapes("Oval 1").Select
Selection.ShapeRange.Line.Weight = 8#
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.SchemeColor = 8
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
End Sub


--

Dave Peterson



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
Shape Outline (border) Neil Pearce Excel Discussion (Misc queries) 1 April 8th 08 12:18 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
ActiveChart.Deselect won't Deselect Mark Stephens Charts and Charting in Excel 2 June 16th 05 02:54 AM
Deleting a shape and the cell contents the shape is in. Dave Peterson[_3_] Excel Programming 1 October 9th 03 03:36 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM


All times are GMT +1. The time now is 11:45 PM.

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"