Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Assigning Macro To Shape

Hello!
I need to make a macro that will create a new worksheet, add a Shape-object
(any one which is similar to button), then assign a macro to that Shape.

I haven't been able to do this. The problem is how to select the
Shape-object properly.

Can you help me!

BR, Tommi


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assigning Macro To Shape

Try something like this
I assume that the macro exist??


Sub test()
Dim Nsheet As Worksheet
Set Nsheet = Worksheets.Add
Nsheet.Shapes.AddShape(msoShapeRectangle, 100, 200, 150, 50).Select
Selection.OnAction = "yourmacro"
Nsheet.Range("A1").Select
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Tommi" wrote in message ...
Hello!
I need to make a macro that will create a new worksheet, add a Shape-object
(any one which is similar to button), then assign a macro to that Shape.

I haven't been able to do this. The problem is how to select the
Shape-object properly.

Can you help me!

BR, Tommi




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Assigning Macro To Shape

Thanks very much Ron!
The problem was not anything more than that I didn't select any range after
assigning macro to a Shape and thus it didn't work.
Now it works!

I am glad that it is possible to ask other users who know things better.

BR,
Tommi

"Ron de Bruin" wrote in message
...
Try something like this
I assume that the macro exist??


Sub test()
Dim Nsheet As Worksheet
Set Nsheet = Worksheets.Add
Nsheet.Shapes.AddShape(msoShapeRectangle, 100, 200, 150, 50).Select
Selection.OnAction = "yourmacro"
Nsheet.Range("A1").Select
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Tommi" wrote in message

...
Hello!
I need to make a macro that will create a new worksheet, add a

Shape-object
(any one which is similar to button), then assign a macro to that Shape.

I haven't been able to do this. The problem is how to select the
Shape-object properly.

Can you help me!

BR, Tommi






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 color macro Edwin Excel Discussion (Misc queries) 0 August 5th 09 07:54 PM
Excel Shape Macro Lenny Excel Discussion (Misc queries) 0 May 19th 08 10:50 PM
assigning macro carrera Excel Discussion (Misc queries) 16 March 21st 08 09:00 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 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 04:24 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"