Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default How to Place a Drawing Object on a Worksheet as a Control?

I've built an optimization model and I would like to create a map-like
interface on a worksheet in which selected sites in the solution are
indicated on the map canvas by unhiding drawing objects. So I need to
place the drawing objects on the worksheet as Controls (i.e. Shapes I
think) but how to do that is not clear since the Control tool box
contains pictures but not shape objects.

Any ideas?


Thanks Much,

SteveM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default How to Place a Drawing Object on a Worksheet as a Control?

On Jan 21, 5:55 am, SteveM wrote:
I've built an optimization model and I would like to create a map-like
interface on a worksheet in which selected sites in the solution are
indicated on the map canvas by unhiding drawing objects. So I need to
place the drawing objects on the worksheet as Controls (i.e. Shapes I
think) but how to do that is not clear since the Control tool box
contains pictures but not shape objects.

Any ideas?

Thanks Much,

SteveM


Do the shapes have to be Control objects?
Shapes can be assigned to macros and can be hidden/unhidden by code.

Ken Johnson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default How to Place a Drawing Object on a Worksheet as a Control?

On Jan 20, 5:41 pm, Ken Johnson wrote:
On Jan 21, 5:55 wrote:

I've built an optimization model and I would like to create a map-like
interface on a worksheet in which selected sites in the solution are
indicated on the map canvas by unhiding drawing objects. So I need to
place the drawing objects on the worksheet as Controls (i.e. Shapes I
think) but how to do that is not clear since the Control tool box
contains pictures but not shape objects.


Any ideas?


Thanks Much,


SteveM


Do the shapes have to be Control objects?
Shapes can be assigned to macros and can be hidden/unhidden by code.

Ken Johnson


Ken,

Can you explain? A control has a project name associated with the
sheet, but a drawing object inserted from the drawing toolbar does
not. How would I refer to the drawing shape object in VB code without
a reference name?

SteveM
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default How to Place a Drawing Object on a Worksheet as a Control?


Hi Steve,
You could give the shape a meaningful name by selecting the shape then
clicking in the name box, which is on the left side of the Formula
Bar, type the name ( eg MyShape1 or whatever, just something that
indicates the shape's role in your project) then press Enter.
After giving the Shape a meaningful name you would refer to it in your
code using...

ActiveSheet.Shapes("MyShape1")

eg ActiveSheet.Shapes("MyShape1").Top = 100 will position it 100
points from the top of the sheet.

If you needed to refer to it often in your code you could use an
Object variable...

Dim Thingy as Shape
Set Thingy = ActiveSheet.Shapes("MyShape1")

Thingy.Top = 100

If you assign a macro to a shape, you can refer to the shape in its
macro using Application.Caller

eg say after clicking the shape you want the shape to be hidden, then
reappear after the code has finished, then the first line of the macro
could be...

ActiveSheet.Shapes(Application.Caller).Visible = False

and the final line...

ActiveSheet.Shapes("MyShape1").Visible = True

Ken Johnson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default How to Place a Drawing Object on a Worksheet as a Control?

Oops!
The last line should have been...
ActiveSheet.Shapes(Application.Caller).Visible = True

Ken Johnson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default How to Place a Drawing Object on a Worksheet as a Control?

On Jan 20, 8:31 pm, Ken Johnson wrote:
Oops!
The last line should have been...
ActiveSheet.Shapes(Application.Caller).Visible = True

Ken Johnson


Ken,

That works! Thanks!

BTW, the Shape.Visible property options only presented msoFalse and
msoTrue when inputing the code which are new to me and apparently do
nothing in this simple case. But True and False do work like desired.

SteveM
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
Erase Drawing Object smandula Excel Programming 3 October 15th 07 03:23 PM
Selecting Drawing Object By Name Zone Excel Programming 3 December 22nd 06 08:21 PM
Drawing Object in a Userform Zone Excel Programming 4 May 9th 06 08:27 PM
Drawing Object Shawn Excel Programming 2 March 2nd 05 03:04 PM
Drawing object references JASon Excel Programming 2 August 28th 03 10:49 PM


All times are GMT +1. The time now is 07:45 AM.

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"