简体   繁体   中英

Excel VBA Javascript Export

I am attempting to export a report from a SQL Server Reporting Services site, and am using Excel 07 and IE7. I have the code all the way up

 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

The site that I'm pulling the data from shows this as it's 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>

When I run my macro, this code does nothing.

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

But when I use the below code from the site Source, I get the Run Time Error 80020101.

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

Can anyone recommend what I can do to pull this data?

So I got the basics done on this file. I opened a new questions specificly for VBA's For Each procedure, but the main Javascript issue here is closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM