Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 在IE中下载变量文件名,无保存提示_Vba_Excel - Fatal编程技术网

Vba 在IE中下载变量文件名,无保存提示

Vba 在IE中下载变量文件名,无保存提示,vba,excel,Vba,Excel,我正在尝试下载一个电子表格,它的名称在每次访问临时文件时都会更改,而不需要处理IE保存提示。intranet站点通过门户进行路由,需要windows身份验证才能登录,然后才能将我带到目的地。到目前为止,我拼凑的内容使我通过windows身份验证,输入适当的信息,然后单击按钮检索查询。理想情况下,我希望直接将信息拉到我的N:驱动器中,而不需要保存提示,只需将其保存为“File.xlsx”;浏览下载/保存提示也可以,但我不知道哪一个更容易或更有效 Sub Automation() Const UR

我正在尝试下载一个电子表格,它的名称在每次访问临时文件时都会更改,而不需要处理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
如果有帮助,则检查click button元素时的代码为:

</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。非常感谢您的任何建议或帮助