VBA 自动化 - 使用 IE 11(64 位)下载文件
VBA Automation - Downloading a file using IE 11 (64bit)
这个问题似乎被问了很多次,但是 none 我找到的解决方案似乎能够解决我的问题。
由于该网页使用的是证书令牌,因此在激活 VBA 脚本之前我不得不手动登录该网页,这没问题。一个重要的注意事项是报告的 link 是动态的,因此我不能 link 直接到报告本身,因此我必须使用我的脚本浏览网页。您可以在下面找到我用来定位 window 我已登录网页的脚本:
Sub WebPageOpen()
Dim HTMLDoc As HTMLDocument
Dim oHTML_Element As IHTMLElement
On Error GoTo Err_Clear
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For X = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(X).document.Location
my_title = objShell.Windows(X).document.Title
If my_title Like "MY Webpage name" Then 'compare to find if the desired web page is already open
Set IE = objShell.Windows(X)
marker = 1
Exit For
Else
End If
Next
If marker = 0 Then
MsgBox ("Webpage is not open - Please log on to webpage")
Exit Sub
Else
End If
Do
' Wait till the Browser is loaded
Loop Until IE.readyState = READYSTATE_COMPLETE
' I have removed all my navigation commands here,as it would just be bloating the query. It clicks the link and the Save/open ribbon appears in IE.
End sub
任何人都可以帮助我解决如何与下载文件时出现的 Open/Save 功能区交互的问题吗?
那个功能区叫通知栏
您可以使用 Alt+N 将焦点放在通知栏上。然后发送 {tab} 键导航到特定按钮。
使用 VBA,您可以使用 Autohotkey.dll 或 AutoItX3.dll 发送这些热键组合。
- 添加对 AutoItX3.dll 的引用(对于 32 位和 64 位 OS)
追加以下
设置 X=CreateObject("AutoItX3.Control")
X.send !N{tab}{down 2}{enter} '这用于另存为
这个问题似乎被问了很多次,但是 none 我找到的解决方案似乎能够解决我的问题。
由于该网页使用的是证书令牌,因此在激活 VBA 脚本之前我不得不手动登录该网页,这没问题。一个重要的注意事项是报告的 link 是动态的,因此我不能 link 直接到报告本身,因此我必须使用我的脚本浏览网页。您可以在下面找到我用来定位 window 我已登录网页的脚本:
Sub WebPageOpen()
Dim HTMLDoc As HTMLDocument
Dim oHTML_Element As IHTMLElement
On Error GoTo Err_Clear
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For X = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(X).document.Location
my_title = objShell.Windows(X).document.Title
If my_title Like "MY Webpage name" Then 'compare to find if the desired web page is already open
Set IE = objShell.Windows(X)
marker = 1
Exit For
Else
End If
Next
If marker = 0 Then
MsgBox ("Webpage is not open - Please log on to webpage")
Exit Sub
Else
End If
Do
' Wait till the Browser is loaded
Loop Until IE.readyState = READYSTATE_COMPLETE
' I have removed all my navigation commands here,as it would just be bloating the query. It clicks the link and the Save/open ribbon appears in IE.
End sub
任何人都可以帮助我解决如何与下载文件时出现的 Open/Save 功能区交互的问题吗?
那个功能区叫通知栏
您可以使用 Alt+N 将焦点放在通知栏上。然后发送 {tab} 键导航到特定按钮。
使用 VBA,您可以使用 Autohotkey.dll 或 AutoItX3.dll 发送这些热键组合。
- 添加对 AutoItX3.dll 的引用(对于 32 位和 64 位 OS)
追加以下
设置 X=CreateObject("AutoItX3.Control")
X.send !N{tab}{down 2}{enter} '这用于另存为