On Double Click or On CTRL Click for many Shapes

dreedgibson

New Member
Joined
Nov 16, 2015
Messages
2
All,
This is my first post to this board, I have tried searching the board and I haven't been able to come up with an answer. I am fairly new to VBA and have a question regarding the on double click private sub and how to assign it to shapes (CTRL click would work as well). I have a sheet that reads an input from range B3:B11 and creates an appropriate number of shapes based on the numbers it reads...

For example Cell A3 is PLEM Cell B3 is 6 thus it creates 6 PLEM shapes in a new build sheet.

With that in mind the following code creates the manifold shapes:
Code:
For i = 1 To iman
    Set man(i, 1) = ws.Shapes.AddShape(65, (i - 1) * 110 + 465, 315, 100, 100)
    man(i, 1).Name = Sheets("Instructions").Range("A7").Value & i
    man(i, 1).TextFrame.Characters.Text = Sheets("Instructions") _
    .Range("A7").Value & i
    man(i, 1).TextFrame.HorizontalAlignment = xlHAlignCenter
    man(i, 1).TextFrame.VerticalAlignment = xlVAlignCenter
    man(i, 1).Fill.ForeColor.RGB = RGB(223, 251, 53)
    man(i, 1).TextFrame.Characters.Font.ColorIndex = 1
[B]    man(i, 1).OnAction = "ManifoldClick" & i[/B]
    ActiveCell.Offset(iplem + ipl + itree + ijumper + i - 1, 0).Value = man(i, 1).Name
Next i

where iman is taken from cell B7 and in this case is 3 (three shapes will be created)

I am most concerned with the bolded line, the goal of the sheet is to be able to rearrange the icons to look like a proper field layout.
However, when the Manifold shapes are clicked, the ManifoldClick sub is run. I would rather have the sub run after a double click so that the shapes can be moved around without annoyance.
Is it possible to assign a double click action in this section of code? If there is, I will be trying to assign it to every shape in the sheet.

Any help would be appreciated, also please feel free to tell me I didn't look enough if there is a thread that I missed that has an answer to something like this.
If you would rather view the spreadsheet send me a PM of your email and I will send it on through,
Thanks very much,
DRG
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi and welcome to the MrExcel Message Board.

It will be easier to do it the other way round.

Assign macros to the shapes but move them by using Alt + Left-Drag.
That will prevent the macro from running when you select a shape.

Also, you might like this.
When you run a macro associated with a shape you can ask for the name of the shape by using Application.Caller.
That way you could have just one macro which runs the appropriate code depending on the name of the clicked shape.
Code:
Sub ShapeClick()
    MsgBox Application.Caller
End Sub
 
Upvote 0
Hi Rick,
I figured there wouldn't be an easy way to do that...

I appreciate the application caller though, I thought I was going to be writing a new sub for each individual shape that was made with the sheet.

Thanks for taking time to help out.

DRG
 
Upvote 0
You're welcome.

Excel is a bit light on shape-driven events.

I am pleased you found the Application.Caller tip useful. It means that you can have just one macro with a Select Case section that directs all the processing.

Regards,
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top