问题
Can i have a link between a button on an IE page and a visio event ? ( for example : changing the color of a shape just by a click on a button on the IE page)
回答1:
yes you should check the get started documentation of jquery
html :
<button id="mybutton" />
<div id="myshape">blabla</div>
javascript :
$('#mybutton').click(function() {
$('#myshape').css('background-color', '#555555');
});
回答2:
Not really very easy unless you have access to the HTML content in IE as well, but you could use a VBA class which implements a "withevents" private variable to capture a reference to a particular element on the page, and which has an event handler to respond to browser-based events. Eg. in a class "clsHTML":
Private WithEvents el As MSHTML.HTMLInputElement
Public Sub SetElement(t As MSHTML.HTMLInputElement)
Set el = t
End Sub
Private Function el_onchange() As Boolean
Debug.Print "captured change: value = " & el.Value
End Function
In other code, create an instance of the class and call "SetElement" using a reference to an element on the page in IE:
Dim objHTML As clsHTML 'global variable
Sub TestEvents()
Dim IE As Object
'set up your IE reference....
Set objHTML = New clsHTML
objHTML.SetElement IE.document.getElementById("tester2")
Debug.Print "set capture"
End Sub
In this instance you're capturing the "change" event on a textbox, but other elements will expose different events....
Edit: I tested this in Excel, but I'm assuming something similar will also work in Visio.
Edit2: you would probably be much better off creating a form in Visio to handle this than sticking with automating IE.
来源:https://stackoverflow.com/questions/7388391/detect-event-on-ie-from-visio