Excel VBA Javascript Export

Excel VBA Javascript Export

本文关键字:Export Javascript VBA Excel      更新时间:2023-09-26

我正在尝试从 SQL Server Reporting Services 站点导出报告,并且使用的是 Excel 07 和 IE7。我有代码一直向上

 Sub TestIE()
 Dim IE2 As Object
 Set IE2 = CreateObject("InternetExplorer.Application")
 IE2.Visible = True
 IE2.navigate "http://www.site.com"
 Application.StatusBar = "Accessing the report"
 Do While IE2.Busy
 Application.Wait DateAdd("s", 1, Now)
 Loop
 Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = IE2.document.parentWindow
 Call CurrentWindow.execScript("$find('ctl31')")
 End Sub

我从中提取数据的网站显示它是Javascript。

 <div class="NormalButton">
 <a class="ActiveLink" onclick="$find('ctl31').exportReport('EXCEL');" 
 href="javascript:void(0)" style="padding:3px 8px 3px 8px;display:block;
 white-space:nowrap;text-decoration:none;">Excel</a>

当我运行宏时,此代码不执行任何操作。

 Call CurrentWindow.execScript("$find('ctl31')")

但是当我使用站点源代码中的以下代码时,我收到运行时错误80020101。

 Call CurrentWindow.execScript("$find('ctl31').exportReport('EXCEL');")

任何人都可以建议我可以做些什么来提取这些数据吗?

所以我完成了这个文件的基础知识。我专门为VBA的For Each过程打开了一个新问题,但是这里的主要Javascript问题已经关闭。