excel - 在 IE 宏中导航网页后保存文件
问题描述
您好我正在尝试自动化我的报告自动化的下载部分。我能够通过导航获取原始数据,但我现在只能下载它,因为我的 IE 是旧版本。弹出“打开”、“保存”、“取消”。我无法发布该网站,因为它是一个客户端网络工具。
评论部分是我迄今为止尝试过的。
Sub Get_RawFile()
'
'
'
Dim IE As New InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim HTMLselect As HTMLSelectElement
'Dim saveInFolder As String, saveAsFilename As String
'saveInFolder = "C:"
'saveAsFilename = "test_" & Format(Sheets("Attendance").Range("X6").Value, "yyyymmdd")
With IE
.Visible = True
.Navigate ("---------------------")
While IE.Busy Or IE.readyState <> 4: DoEvents: Wend
Set HTMLDoc = IE.document
HTMLDoc.all.UserName.Value = Sheets("Data Dump").Range("A1").Value
HTMLDoc.all.Password.Value = Sheets("Data Dump").Range("B1").Value
HTMLDoc.getElementById("login-btn").Click
While IE.Busy Or IE.readyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("0:00:05"))
Set objButton = HTMLDoc.getElementById("s2id_ddlReportType")
Set HTMLselect = HTMLDoc.getElementById("ddlReportType")
objButton.Focus
HTMLselect.Value = "2"
Set HTMLselectZone = HTMLDoc.getElementById("ddlTimezone")
HTMLselectZone.Value = "PST8PDT"
Set subgroups = HTMLDoc.getElementById("s2id_ddlSubgroups")
subgroups.Click
Set subgroups2 = HTMLDoc.getElementById("ddlSubgroups")
subgroups2.Value = "1456_17"
HTMLDoc.getElementById("dtStartDate").Value = Format(Sheets("Attendance").Range("B6").Value, "yyyy-mm-dd")
HTMLDoc.getElementById("dtEndDate").Value = Format(Sheets("Attendance").Range("X6").Value, "yyyy-mm-dd")
HTMLDoc.getElementById("btnGetReport").Focus
HTMLDoc.getElementById("btnGetReport").Click
Application.Wait (Now + TimeValue("0:00:10"))
HTMLDoc.getElementById("btnDowloadReport").Click 'Download report button
'saveInFolder, saveAsFilename
End With
End Sub
解决方案
推荐阅读
- typescript - ESLint 配置中的“parser”和“parserOptions.parser”有什么区别?
- angular - 使用 Angular 中的主题通过服务向组件发送数据
- java - 如何将java文件转换为在Android上运行的apk
- go - 无法在 WSL 上安装 go 工具
- java - 使用 Jackson 转换日期/时间时保留时区信息
- microsoft-graph-api - 从 Microsoft Graph 客户端获取响应标头
- css - 如何使图像溢出容器宽度而不是 100% 高度上的翘曲
- java - 为什么我自己的异常不需要参数?
- git - 行更改的 Git 交叉兼容性问题
- d3.js - 无法让 D3 .on('mouseover', ...) 工作