Internet Explorer上的VBA SendKeys“SaveAs”会弹出下载文件夹

时间:2016-07-11 00:32:03

标签: excel vba excel-vba internet-explorer-8

这是我单击“另存为”按钮的代码。我的代码基于这个答案:VBA interaction with internet explorer,但它似乎没有用。

我该怎么办?

  Private Declare Function SetForegroundWindow Lib "user32" (ByVal HWND As     Long) As Long
    Dim HWNDSrc As Long



  Public Sub IE_Autiomation3()


Dim i As Long
Dim ie As Object
Dim objElement As Object
Dim objCollection, obj As Object
Dim GoObj, ClassObj As Object



' Create InternetExplorer Object
Set ie = CreateObject("InternetExplorer.Application")

HWNDSrc = ie.HWND


' You can uncoment Next line To see form results
ie.Visible = True




' Send the form data To URL As POST binary request
ie.navigate "http://www.otcmarkets.com/research/stock-screener"


' Wait while IE loading...
Do While ie.Busy
    Application.Wait DateAdd("s", 1, Now)
Loop

' Find 2 input tags:
'   1. Text field
'   <input type="text" class="textfield" name="s" size="24" value="" />
'
'   2. Button
'   <input type="submit" class="button" value="" />

Application.StatusBar = "Search form submission. Please wait..."

Set objCollection = ie.document.getElementsByTagName("input")

  Set ClassObj = ie.document.getElementsByTagName("a")







 ClassObj(53).Click

  WaitForIE ie, HWNDSrc, 1
       SetForegroundWindow HWNDSrc


 Application.SendKeys ("%s"), True

End Sub

0 个答案:

没有答案