Author Topic: Run "Private Sub" in "ThisDocument" every time you move a shape or similar  (Read 66 times)

0 Members and 1 Guest are viewing this topic.

smelvadj

  • Newbie
  • *
  • Posts: 3
Hello!

I have read many topic with a similar question. Yet, this have not solved my problem.
I have some code which interchanges data between connected shapes. When the connection of shapes changes, i therefore need to run the VBA Macro again.

Do you have a method to run the macro in "ThisDocument" every time a connection is changed, every time a shapes i moved, or similar ?

Thank you very much!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3399
  • Ideas Visio-lized into solutions
Re: Run "Private Sub" in "ThisDocument" every time you move a shape or similar
« Reply #1 on: February 13, 2019, 12:58:06 PM »
I've not done this, but would recommend against.  Such a macro will fire on every shape that is moved or changed.  This will cause Visio to run very slowly.  You will not be happy with the degraded performance.

Anyway, that's my 2 cents worth. 

Wapperdude
Visio 2019 Pro

smelvadj

  • Newbie
  • *
  • Posts: 3
Thank you for the reply.

What would you then recommend. I want the shape information to update automatically, and not by clicking a button.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3399
  • Ideas Visio-lized into solutions
I wouldn't do it automatically.  By its nature, it's intrusive and makes the drawing process very slow.  Perhaps the changes were a bad idea, you might not want to save/update those.  Sometimes a move is temporary, and shape gets put back to where it was.  Don't need to save/update that.

The options would be:
1) have the macro fire every 10 minutes...still not my preference...captures things that may not be worth/need capturing.
2) have ability to run macro at users choice...a good feature.  But, probably needs additional capability
3) watch to see if document changed, if so, then fire macro before document closes.  A full update at end of session.

I'm sure there are other scenarios...these come to mind.



Visio 2019 Pro

smelvadj

  • Newbie
  • *
  • Posts: 3
Hi wapperdude,

Thank you for the proposals.

Is it possible to run the macro if a shape connection is changed ?

I connect my shapes with connection points. When i connect one shape to another, my macro copy data from the new shape to the other shape. If i disconnect the shapes again, the data for the shapes are reset by the macro.