从 visio 检测 IE 上的事件

发布于 2024-12-04 04:26:00 字数 68 浏览 0 评论 0原文

我可以在 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只怪假的太真实 2024-12-11 04:26:00

除非您也可以访问 IE 中的 HTML 内容,否则这并不容易,但是您可以使用 VBA 类,该类实现“withevents”私有变量来捕获对页面上特定元素的引用,并且该类具有事件处理程序响应基于浏览器的事件。例如。在“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”:

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

在此实例中,您将捕获文本框上的“change”事件,但其他元素会暴露不同的事件......

编辑:我在 Excel 中测试了这一点,但我假设类似的东西也适用于 Visio。

Edit2:在 Visio 中创建一个表单来处理这个问题可能比坚持使用自动化 IE 更好。

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.

旧城烟雨 2024-12-11 04:26:00

是的,你应该检查 jquery html 的入门文档

<button id="mybutton" />
<div id="myshape">blabla</div>

javascript :

$('#mybutton').click(function() {
    $('#myshape').css('background-color', '#555555');
});

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');
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文