通过网站上的文件夹选择器从已知位置自动选择图片

问题描述 投票:1回答:1

我在网站上打开的文件夹选择器有问题,要求我上传图片。我可以登录网站,可以打开浏览链接显示所在的链接,也可以单击它。但是,我无法上传已知位置,也无法单击上传按钮。链接位于fw后面,因此所有链接都被隐藏。

    Dim ie As New InternetExplorer
    Dim myElem As Variant
        ie.Visible = True

     With ie
         Const MAX_WAIT_SEC As Long = 10
        Dim t As Date, ele As Object
        t = Timer
        While .Busy Or .readyState < 4: DoEvents: Wend
     End With
    ie.document.getElementById("picture").Click
'this cell contains picture link
   Sheets("picture").Range("A12").Copy 

          With ie
     While .Busy Or .readyState < 4: DoEvents: Wend
     End With
    ie.document.getElementById("browse").Click
              With ie
     While .Busy Or .readyState < 4: DoEvents: Wend
     End With
'folder picker is active now and code should be written here 
         With ie
     While .Busy Or .readyState < 4: DoEvents: Wend
     End With
     ie.document.getElementById("upload").Click
     End With

手动,我可以使用ctrl + v然后输入,它可以正常工作,但是对于宏,我使用下面的代码,但对我来说不起作用。

SendKeys "^v", True
SendKeys "enter", True

vba web-scraping sendkeys
1个回答
0
投票

这不是您发送ENTER键的方式。参见MSDN Guidance

SendKeys "~", True '// Send {ENTER} key

当前您正在字面意义>>向窗口发送文本"enter"

© www.soinside.com 2019 - 2024. All rights reserved.