在IE中下载变量文件名而没有保存提示

时间:2017-01-17 17:03:48

标签: excel vba excel-vba

我正在尝试下载一个电子表格,每次访问时都会更改其名称,而不会处理IE保存提示。 Intranet站点通过门户网站路由,这需要Windows身份验证才能登录,然后再将我带到目的地。到目前为止我拼凑到一起让我通过Windows身份验证,输入相应的信息并单击按钮来检索查询。理想情况下,我想直接将信息提取到我的N:驱动器而不保存提示,只需将其保存为“File.xlsx”;导航下载/保存提示也可以,但我不知道哪个更容易或更有效。

Sub Automation()

Const URL1 = "https://website/q/?ICAction=ICQryNameExcelURL=PUBLIC.Z_FILE_DESIGN"

Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim DValue As String

Set IE = New SHDocVw.InternetExplorerMedium
DValue = Format(Date, "mm/dd/yyyy")

With IE
    .Navigate URL1
    .Visible = True
End With

    Do
        DoEvents
    Loop Until IE.ReadyState = 4 And Not IE.Busy

IE.Navigate "javascript: signinIWA();"

    Do
        DoEvents
    Loop Until IE.ReadyState = 4 And Not IE.Busy

Set HTMLDoc = IE.Document
HTMLDoc.getElementById("InputKeys_Z_File").Value = "q32e751"
HTMLDoc.getElementById("InputKeys_EFFDT").Value = DValue

    Do
        DoEvents
    Loop Until IE.ReadyState = 4 And Not IE.Busy

HTMLDoc.getElementById("#ICQryDownloadExcelFrmPrompt").Click

End Sub

如果它有帮助,检查点击按钮元素时的代码:

</DIV></td>
</tr>
<input type='hidden' name='ICExcel' id='ICExcel' value='1' />
</table>
<a class='PSPUSHBUTTON' style='background-Color: transparent;border:0;' id = 'Left' role='presentation'><span style='background-Color: transparent;border:0;'><input type='button' class='PSPUSHBUTTON' value='View Results' id='#ICQryDownloadExcelFrmPrompt' onclick="submitAction_win4(this.form,'#ICQryDownloadExcelFrmPrompt');" tabindex='14' /></span></a>
</DIV>
<DIV id='win4divQUERYRESULT'><table cellpadding='2' cellspacing='0' width='90%'>
<tr><td>
</td></tr>
<tr><td>`

每次访问时都会发生变化的一件事是onclick动作和queryresult行后面的数字“4”。此外,当打开临时文件时,它始终具有相同的基本名称 - Z_FILE_DESIGN,但包括附加的随机数,例如。 Z_FILE_DESIGN_12345。非常感谢任何建议或帮助。

0 个答案:

没有答案
相关问题