VBA for executing macro when a shape is moved/altered?

frabulator

Active Member
Joined
Jun 27, 2014
Messages
256
Office Version
  1. 2019
Platform
  1. Windows
I am looking for a way to execute a macro when an object with a specific name is updated, moved or changed. Is this possible, and if it is, could someone please point me in the correct direction or give me a sample code?

Many thanks!

Frab~
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Re: VBA for exicuting macro when a shape is moved/altered?

bump :)
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

Be more specific. What type object?
Generally speaking I do not believe a script will run when a object is moved.
Now changing a object may cause a script to run but we would need to know what type change.

Give us a example of something you want to do.
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

Be more specific. What type object?

Give us a example of something you want to do.

Sorry, I should have been more specific.

I have a shape (a rectangle to be precise) with a unique name ("DrawingWindowEample"). Inside this rectangle shape I have other shapes (lines, circles, arcs, etc) that are populated within that rectangle's borders. All of these objects are populated via a Macro.

What I would like is a way to execute that macro when the rectangle is changed in any way; size changes, location changes, width, etc. By doing so I want to update/re-populate the shapes inside the rectangle automatically. Is this possible?
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

Sorry, I should have been more specific.

I have a shape (a rectangle to be precise) with a unique name ("DrawingWindowEample"). Inside this rectangle shape I have other shapes (lines, circles, arcs, etc) that are populated within that rectangle's borders. All of these objects are populated via a Macro.

What I would like is a way to execute that macro when the rectangle is changed in any way; size changes, location changes, width, etc. By doing so I want to update/re-populate the shapes inside the rectangle automatically. Is this possible?

I know of no way to do that. But there are a lot of other people who may have a answer for you. We will see who else here may have another answer for you.
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

I know of no way to do that. But there are a lot of other people who may have a answer for you. We will see who else here may have another answer for you.
Well thank you for your help anyway :)
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

bump :)
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

bump :?
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

If you group the shapes together then any change in size or location of the rectangle container shape should also affect the shapes that are inside it.

To group the shapes just select them all with the mouse, rightclick the mouse and choose Grroup from the right-click menu.
 
Upvote 0
Re: VBA for exicuting macro when a shape is moved/altered?

If you group the shapes together then any change in size or location of the rectangle container shape should also affect the shapes that are inside it.

While that is neat, and I think it would work in many situations, it will not work for what I want to do. If the rectangle is resized I will need to redraw the shapes inside of it as they should not be scaled with the rectangle. The shapes inside need to stay the same aspect ration when the rectangle is resized.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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