PC Review


Reply
Thread Tools Rate Thread

How to Assign Worksheet Module to a Shape

 
 
K
Guest
Posts: n/a
 
      23rd Oct 2008
Hi all, I have macro in Worksheet Module (see below)

Private Sub dd()
ActiveSheet.Range("A1").Value = "OK"
End Sub

I have a Rectangle Shape on my sheet to which I gave the name "shp".
I want to assign above macro to this shap by another macro and this
macro I want to put in normal Module.
The only problem is that I don’t want other macro which I'll put in
normal Module to be like this (see below)

Sub attch_maro()
ActiveSheet.Shapes("shp").Select
Selection.OnAction = "Sheet1.dd"
End Sub

I want other macro to be like this (see below)

Sub attch_maro()
ActiveSheet.Shapes("shp").Select
Selection.OnAction = ActiveSheet.dd
End Sub

I tried this but for some reason I am getting error and it
highlighting this line "Selection.OnAction = ActiveSheet.dd".
Basically I want to assign activesheet macro to my shape. I hope I
was able to explain my problem. Please can any friend can help
 
Reply With Quote
 
 
 
 
scattered
Guest
Posts: n/a
 
      23rd Oct 2008
On Oct 23, 11:37*am, K <kamranr1...@yahoo.co.uk> wrote:
> Hi all, *I have macro in Worksheet Module (see below)
>
> Private Sub dd()
> ActiveSheet.Range("A1").Value = "OK"
> End Sub
>
> I have a Rectangle Shape on my sheet to which I gave the name "shp".
> I want to assign above macro to this shap by another macro and this
> macro I want to put in normal Module.
> The only problem is that I don’t want other macro which I'll put in
> normal Module to be like this (see below)
>
> Sub attch_maro()
> ActiveSheet.Shapes("shp").Select
> Selection.OnAction = "Sheet1.dd"
> End Sub
>
> I want other macro to be like this (see below)
>
> Sub attch_maro()
> ActiveSheet.Shapes("shp").Select
> Selection.OnAction = ActiveSheet.dd
> End Sub
>
> I tried this but for some reason I am getting error and it
> highlighting this line "Selection.OnAction = ActiveSheet.dd".
> Basically I want to assign activesheet macro to my shape. *I hope I
> was able to explain my problem. *Please can any friend can help


Maybe something like:

Selection.OnAction = ActiveSheet.Name & ".dd"

hth

-scattered
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use VBA to assign Macro to Shape within a Group of Shapes? MikeZz Microsoft Excel Programming 1 28th Jan 2009 01:25 AM
assign excel 2003 macro with parms to shape =?Utf-8?B?TWFydmlu?= Microsoft Excel Programming 2 3rd Jan 2007 07:33 AM
How to assign a macro to a shape in a word document? =?Utf-8?B?RnJhbms=?= Microsoft Word Document Management 1 25th Feb 2005 01:45 AM
Active Shape Module Eric Microsoft Powerpoint 2 20th Feb 2004 02:17 PM
Assign code to shape Jacob Microsoft Excel Programming 1 4th Nov 2003 02:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:56 PM.