我正在尝试使用VBA通过Internet Explorer下载文件(安全登录后) 它是一个JSON文件,导航到该文件时,我会弹出对话框“您要打开还是保存文件”
我在帖子中尝试了许多解决方案,但是似乎都没有用,请对此提供帮助。
我尝试了来自stackoverflow,reddit和excel论坛的各种解决方案
这是我当前使用IE登录到该网站的VBA:
Sub login()
Const Url$ = "https:/xxx.com/2020-01-01"
Dim UserName As String, Password As String, LoginData As Worksheet
Set LoginData = ThisWorkbook.Worksheets("Sheet1")
UserName = LoginData.Range("A1")
Password = LoginData.Range("A2").Value
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie
.navigate Url
ieBusy ie
.Visible = True
Dim oLogin As Object, oPassword As Object
Set oLogin = .document.getElementsByName("username")(1)
Set oPassword = .document.getElementsByName("password")(0)
oLogin.Value = UserName
oPassword.Value = Password
.document.forms(0).submit
End With
End Sub
Sub ieBusy(ie As Object)
Do While ie.Busy Or ie.readyState < 4
DoEvents
Loop
End Sub