Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Selecting drawing objects or shapes in a macro

I have an application where an Excel cell contains either
a red dot or a red dot with a circle around it. These are
drawing objects or shapes. When I delete the contents of
a cell, they stay put. I have to select them individually
and delete them, which is what I want to automate with a
bit of code. What I want to do is delete the dot within
the active cell, and delete the contents of the cell. I
just can't figure out how to select the dot in the active
cell without knowing the individual shape range. What I
want to do is:

ActiveSheet.Shapes("Oval 955").Select

But I want to select whichever "Oval" is in the active
cell. Is that possible?

Thanks,

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Selecting drawing objects or shapes in a macro

This will delete the shape in the active cell (assuming the shape occupies
only one cell) and clear the contents of the active cell, which is what I
think you want to do (I don't guarantee this is the easiest way):

Sub Tester2()
With ActiveSheet
For i = 1 To .Shapes.Count
x = .Shapes(i).TopLeftCell.Row
y = .Shapes(i).TopLeftCell.Column
If ActiveCell.Address = .Cells(x, y).Address Then
.Shapes(i).Delete
ActiveCell.ClearContents
Exit For
End If
Next i
End With
End Sub

HTH,
Shockley


"John DeFiore" wrote in message
...
I have an application where an Excel cell contains either
a red dot or a red dot with a circle around it. These are
drawing objects or shapes. When I delete the contents of
a cell, they stay put. I have to select them individually
and delete them, which is what I want to automate with a
bit of code. What I want to do is delete the dot within
the active cell, and delete the contents of the cell. I
just can't figure out how to select the dot in the active
cell without knowing the individual shape range. What I
want to do is:

ActiveSheet.Shapes("Oval 955").Select

But I want to select whichever "Oval" is in the active
cell. Is that possible?

Thanks,

John




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Selecting drawing objects or shapes in a macro


Did the trick exactly as I wanted, thanks much.

John


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting drawing objects or shapes in a macro

I created a template where users may want to show two black boxes on the
page at any point. The sheet has to be printed two ways. Once plain
and once with these two black boxes which cover up the values in two
columns. I created buttons to turn these boxes "on" and "off." I
don't delete the boxes when the user wants to change them, I just have
a macro attached the buttons which change their color to white (or
transparent).

If you happen to create buttons to toggle your circles, you can right
click on the button, choose Format Control, and uncheck Print object
under the Properties tab. This way, the user can see the buttons at
all times, but they won't print.

I see you already know the name of your object. The only tricky part
about this is that.. if you protect the sheet, you have to make sure
that either object your are selecting to change is in an unlocked cell
OR you choose to allow the user to "Edit Objects." If you allow them
to edit objects, they could change the buttons on your form, but you
can always send them to another cell so that they don't even notice
they have this privilege. You need to go to your VB editor and create
a module under your project, then add this... to some extent. Then you
would have to go back to your sheet and attach the macros to your
buttons (if you're going to use buttons).

Your code would look like:


Code:
--------------------

Sub DotOff()

ActiveSheet.Shapes("Oval 26").Select
Selection.ShapeRange.Fill.Visible = msoFalse
Range("A10").Select

End Sub

Sub DotOn()

ActiveSheet.Shapes("Oval 26").Select
Selection.ShapeRange.Fill.Visible = msoTrue
Range("A10").Select

End Sub

--------------------



If you want to do something tricky like send the user back to whatever
range they were in... you'll have to assign their range to some
variable, then send them there afterwards. I'll let you figure that
one out. Its too early in the morning for me!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

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
Excel 2007: Selecting multiple objects by drawing a selection box panalysis Excel Discussion (Misc queries) 4 April 2nd 23 07:41 PM
drawing shapes move when printing Barry_in_Oz Charts and Charting in Excel 2 October 5th 10 04:57 AM
selecting multiple objects with macro Memphus01 Excel Discussion (Misc queries) 3 December 2nd 08 07:30 PM
When drawing shapes in excel the shapes keep disappearing Tape Excel Discussion (Misc queries) 1 October 6th 06 04:23 PM
Drawing shapes in a chart ChadTarget Charts and Charting in Excel 1 September 21st 06 09:07 AM


All times are GMT +1. The time now is 03:49 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"