#1   Report Post  
skid812pb
 
Posts: n/a
Default AutoShape

Is there a way to automaticlly assign a macro to and autoshape object in VB,
if there is Could some please help. Thanks.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default


ActiveSheet.Shapes("Autoshape 2").OnAction = "myMacro"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"skid812pb" wrote in message
...
Is there a way to automaticlly assign a macro to and autoshape object in

VB,
if there is Could some please help. Thanks.



  #3   Report Post  
skid812pb
 
Posts: n/a
Default

Thanks that worked great, but now I have another problem, I have several
autoshapes on my worksheet and I need to find a way to tell which shape was
selected if it is possible

Thanks again

"skid812pb" wrote:

Is there a way to automaticlly assign a macro to and autoshape object in VB,
if there is Could some please help. Thanks.

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

You're assigning the same macro to various shapes and want to determine which
shape was clicked on to start the macro?

If yes, then you can use Application.caller to get the name of the shape. And
you can find out more about the shape, too:

Option Explicit
Sub testme()

Dim myShape As Shape

MsgBox Application.Caller

Set myShape = ActiveSheet.Shapes(Application.Caller)

With myShape
MsgBox .Name & vbLf & .TopLeftCell.Address
End With

End Sub

skid812pb wrote:

Thanks that worked great, but now I have another problem, I have several
autoshapes on my worksheet and I need to find a way to tell which shape was
selected if it is possible

Thanks again

"skid812pb" wrote:

Is there a way to automaticlly assign a macro to and autoshape object in VB,
if there is Could some please help. Thanks.


--

Dave Peterson
  #5   Report Post  
skid812pb
 
Posts: n/a
Default

Thanks Dave, That is what I was Lookin for.

"Dave Peterson" wrote:

You're assigning the same macro to various shapes and want to determine which
shape was clicked on to start the macro?

If yes, then you can use Application.caller to get the name of the shape. And
you can find out more about the shape, too:

Option Explicit
Sub testme()

Dim myShape As Shape

MsgBox Application.Caller

Set myShape = ActiveSheet.Shapes(Application.Caller)

With myShape
MsgBox .Name & vbLf & .TopLeftCell.Address
End With

End Sub

skid812pb wrote:

Thanks that worked great, but now I have another problem, I have several
autoshapes on my worksheet and I need to find a way to tell which shape was
selected if it is possible

Thanks again

"skid812pb" wrote:

Is there a way to automaticlly assign a macro to and autoshape object in VB,
if there is Could some please help. Thanks.


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default AutoShape

Hi Dave,

Just found this thread. I was looking for something similar, BUT, when
selecting the shape, I want the shape name to be used as criteria1 in my
small one liner macro .... Selection.AutoFilter Field:=1, Criteria1:="M/162",
rembering I hav many shapes and do not want an individual macro for each.

Cheers

"Dave Peterson" wrote:

You're assigning the same macro to various shapes and want to determine which
shape was clicked on to start the macro?

If yes, then you can use Application.caller to get the name of the shape. And
you can find out more about the shape, too:

Option Explicit
Sub testme()

Dim myShape As Shape

MsgBox Application.Caller

Set myShape = ActiveSheet.Shapes(Application.Caller)

With myShape
MsgBox .Name & vbLf & .TopLeftCell.Address
End With

End Sub

skid812pb wrote:

Thanks that worked great, but now I have another problem, I have several
autoshapes on my worksheet and I need to find a way to tell which shape was
selected if it is possible

Thanks again

"skid812pb" wrote:

Is there a way to automaticlly assign a macro to and autoshape object in VB,
if there is Could some please help. Thanks.


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default AutoShape

Check your other post.

But your criteria seems to have changed.

I wouldn't use slashes in names of shapes. I'd use an underscore.

So if you're using xl2k or higher, make a change:

...., Criteria1:=" " & replace(myShape.Name, "_", "/")



Scoop wrote:

Hi Dave,

Just found this thread. I was looking for something similar, BUT, when
selecting the shape, I want the shape name to be used as criteria1 in my
small one liner macro .... Selection.AutoFilter Field:=1, Criteria1:="M/162",
rembering I hav many shapes and do not want an individual macro for each.

Cheers

"Dave Peterson" wrote:

You're assigning the same macro to various shapes and want to determine which
shape was clicked on to start the macro?

If yes, then you can use Application.caller to get the name of the shape. And
you can find out more about the shape, too:

Option Explicit
Sub testme()

Dim myShape As Shape

MsgBox Application.Caller

Set myShape = ActiveSheet.Shapes(Application.Caller)

With myShape
MsgBox .Name & vbLf & .TopLeftCell.Address
End With

End Sub

skid812pb wrote:

Thanks that worked great, but now I have another problem, I have several
autoshapes on my worksheet and I need to find a way to tell which shape was
selected if it is possible

Thanks again

"skid812pb" wrote:

Is there a way to automaticlly assign a macro to and autoshape object in VB,
if there is Could some please help. Thanks.


--

Dave Peterson


--

Dave Peterson
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
Mouse over effect on autoshape Mark Stephens Charts and Charting in Excel 1 May 7th 05 03:54 PM
Rename autoshape Mark Stephens Excel Discussion (Misc queries) 2 April 2nd 05 11:47 PM
Text in autoshape not displayed Gaurav Excel Discussion (Misc queries) 2 April 1st 05 05:57 PM
AutoShape Positioning? Ken Excel Discussion (Misc queries) 2 February 8th 05 11:45 PM
Put an autoshape in a cell based on another cells content Jo Excel Worksheet Functions 7 November 12th 04 04:34 PM


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