从 visio 检测 IE 上的事件 [英] detect event on IE from visio

查看:19
本文介绍了从 visio 检测 IE 上的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 IE 页面上的按钮和 visio 事件之间建立链接吗?(例如:只需点击 IE 页面上的按钮即可更改形状的颜色)

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)

推荐答案

不是很容易,除非您也可以访问 IE 中的 HTML 内容,但是您可以使用实现withevents"私有变量的 VBA 类来捕获对页面上特定元素的引用,该元素有一个事件处理程序来响应基于浏览器的事件.例如.在clsHTML"类中:

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 

在其他代码中,创建类的实例并使用对 IE 中页面上元素的引用调用SetElement":

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....

我在 Excel 中对此进行了测试,但我假设类似的东西也适用于 Visio.

I tested this in Excel, but I'm assuming something similar will also work in Visio.

Edit2:与坚持使用自动化 IE 相比,在 Visio 中创建一个表单来处理这个问题可能要好得多.

you would probably be much better off creating a form in Visio to handle this than sticking with automating IE.

这篇关于从 visio 检测 IE 上的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆