This is related to this question How do I programmatically/automatically change the text formatting for the text of a Visio shape after I am done with the editing?
There I tried to use some code that would be executed when the text of a shape is edited For some reasons, as described there, in some situations which I could not isolate the code is executed endlessly. That is probably because the script calls itself in a loop. The code is supposed to be executed every time the text of the shape is edited BUT the code itself changes the color of the text. I guess that would count as a new text change and so on.
I am thinking about using the event called TextChanged. According with the documentation this should execute the code when the user finished the editing http://msdn.microsoft.com/en-us/library/office/ff768749.aspx
I could not find a example of using such event in VBA and here is where I need your help thanks in advance Uni
This is how I tested: I used CallThis('ThisDocument.warning") to call the procedure below from "TheText" event of that shape (available via the shapesheet)
Sub warning(oShape As Visio.Shape) MsgBox ("Text edited") End Sub
This gets executed like three times if I star editing the text of a shape and I press the space key (adding a space to the existing text)
Ok here is how you do it:
Open the Code editor In the Project explorer select "ThisDocument" Next in the ObjectWindow select Document Then in the Method dropdown box select ShapeExitedTextEdit You will see a skeleton procedure like below
Private Sub Document_ShapeExitedTextEdit(ByVal oShape As IVShape)
End Sub
There is where you add the code that you want to be executed every time when the editing if finished