Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default How to Assign Worksheet Module to a Shape

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How to Assign Worksheet Module to a Shape

On Oct 23, 11:37*am, K 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
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
assign excel 2003 macro with parms to shape Marvin Excel Programming 2 January 3rd 07 07:33 AM
Calling worksheet module from other module. Michael Malinsky Excel Programming 2 December 14th 05 08:47 PM
Run worksheet module code from workbook module? keithb Excel Programming 1 August 14th 05 04:04 AM
Assign Value to Module Level Variable monir Excel Programming 21 March 23rd 05 03:05 AM
Assign code to shape Jacob Excel Programming 1 November 4th 03 02:53 PM


All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"