用于与Internet Explorer交互的VB脚本"选择要上载的文件"对话窗口

时间:2015-03-05 15:45:40

标签: internet-explorer vbscript dialog

我需要使用VB脚本使用“选择要上载的文件”窗口上传文件。我已经能够导航到页面并“单击”按钮打开窗口,但无法与其进行交互。

On Error Resume Next
Const PAGE_LOADED = 4
Set IE = CreateObject("InternetExplorer.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SHL = CreateObject("WScript.Shell")

Call IE.Navigate("www.myURL.com")
IE.Visible = True
Do Until IE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop

IE.Document.all.username.Value = "somebody@domain.com"
IE.Document.all.password.Value = "password"
IE.Document.all.tenantName.Value = "tenantName"
If Err.Number <> 0 Then
    msgbox "Error: " & err.Description
End If
IE.document.Forms(0).Submit
Wait IE, 500

IE.Navigate "www.PageWhereButtonExists.com"
Wait IE, 500

REM This opens a "Choose File to Upload" Dialog window, but I'm unable to interact with it.
IE.Document.getElementByID("P1_FILE").Click

Set IE = Nothing

Sub Wait(IE, SleepInterval)
    Do
        WScript.Sleep SleepInterval
    Loop While IE.ReadyState < 4 And IE.Busy
End Sub

0 个答案:

没有答案