使用打开的Windows资源管理器并选择文件以在Internet Explorer上上传文件

时间:2019-07-01 20:52:52

标签: excel vba internet-explorer windows-explorer

我正在尝试将大量文档上载到SharePoint中的文档上载/创建中。我正在使用VBA导航到网站,请点击上传按钮。它拉起文件浏览器。我的问题是,如何导航到该文件夹​​并选择一个特定文件?

Sub uploader()
    Set ie = CreateObject("InternetExplorer.Application") ' creates new instance of internet explorer
    ie.Visible = True
    ie.navigate ("restricted website, redacted for this post")

    Do
        DoEvents
    Loop Until ie.readystate = 4 ' waits until ready

    Application.Wait (Now + TimeValue("00:00:03"))
    ie.document.getElementsByClassName("btn btn-default btn-sm")(1).Click ' clicks upload doc button
    Application.Wait (Now + TimeValue("00:00:03"))
    ie.document.getElementsByClassName("ms-dlgFrame")(0).contentDocument.getElementById("ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_OpenWithExplorerLink").Click ' clicks upload, opens file explorer
    'here i need it to navigate down the path and select the file, using the windows explorer that was just opened.
End Sub

我不希望它拉起一个新的文件浏览器。是否可以从已经打开的资源管理器中选择要上传的文件?

0 个答案:

没有答案