从Access VBA调用Javascript函数 [英] Calling Javascript function from access VBA

查看:71
本文介绍了从Access VBA调用Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在访问vba中,我能够从网站检索href标签,但是我发现href值触发的是javascript函数而不是链接. javascript函数将用户定向到我想要的链接.我的问题是:如何通过VBA触发该Javacript函数?

in access vba I'm able to retrieve an href tag from a website, however I found out that the href value triggers a javascript function rather than a link. The javascript function directs the user to a link that I want. My question is: how do I trigger that javacript function via VBA?

        Set ie1 = New InternetExplorer
        ie1.Navigate b.href 'Error here

        'wait for website to load
        Do: Loop While ie1.Busy Or ie1.ReadyState <> 4

        Set blist = HTML.getElementsByTagName("td")

        For Each c In blist

            address = c.innerText
            Debug.Print address

        Next c

b看起来像这样<a href="javascript:dspctry(71)">DNK</a>

推荐答案

解决了这个问题,我使用IE.Document.parentWindow.excScript(b.href,"Javacript")来调用javascript函数,同时将IE.Document设置为我目前的那个.

Solved it, I used IE.Document.parentWindow.excScript(b.href,"Javacript") to call the javascript function while set its IE.Document to my current one.

            'b.Click
            Call HTML.parentWindow.execScript(b.href, "Javascript")
            Do: Loop While ie.Busy Or ie.ReadyState <> 4

            Set blist = HTML.getElementsByTagName("td")

            For Each c In blist

                address = c.innerText
                If InStr(address, "Email: ") Then
                    Debug.Print address
                End If

            Next c

            Set HTML = Nothing
            Exit Function

这篇关于从Access VBA调用Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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