VBA自动将ie11另存为对话框

时间:2018-09-24 17:39:18

标签: vba automation internet-explorer-11 sendkeys save-as

在大型自动化项目上,我距成功仅一步之遥。我已经自动完成了动态下载,直到IE11另存为对话框。这就是我卡住的地方。我需要1)输入一个动态文件名并保存到一个动态文件夹(全部基于单元格值)。 2)在覆盖任何更新对话框的同时单击“保存”

限制;如果您建议这样做,则无法根据URL下载。我正在处理一个安全站点和一个时髦的URL,该URL只能通过下面的For Next循环访问。据我所知,我仅限于处理此SaveAs框。

这是我到目前为止所拥有的;

Sub savedownload()


Dim objIE As InternetExplorer
Set objIE = New InternetExplorer

objIE.Visible = True

objIE.navigate Sheet3.Range("A1").Value ' this is where the dynamic URL is updated
 Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
 objIE.document.getElementById("PrintFormat").Value = "Pdf"
 Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop


Dim list As Object, item As Object
Set list = objIE.document.getElementsByTagName("a")
For Each item In list
If item.innerText = "Export" Then
    item.Click
    Exit For
End If
Next

Application.Wait (Now + TimeValue("0:00:05"))

Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{DOWN}", True
Application.SendKeys "{DOWN}", True
Application.SendKeys "{RETURN}", True

'this is where the dialoge box comes up, but I cant seem to send a dynamic string of text to the file name/path field

End Sub

我也附上了截图。可以发送密钥吗?有没有办法调用SaveAs窗口并放入动态文件名?我可以给它加上一个文件名,然后用SendKeys保存它,但是我想有一种更好的方法,可以将整个动态字符串发送到对话框中的FileName字段。

谢谢您的建议。

IE11另存为对话框的屏幕截图

enter image description here

0 个答案:

没有答案