gpt4 book ai didi

excel - 如何在 vba Excel 中自动上传文件 "Choose File To Upload"

转载 作者:行者123 更新时间:2023-12-04 20:23:40 25 4
gpt4 key购买 nike

我在 Internet Explorer 中自动上传文件时遇到问题。我在 VB 中也有文件,它命名为 Upload.vbs。
错误图片:
enter image description here
点击浏览按钮的代码:

        Set fileS = HTMLdoc.getElementsByTagName("input")

For Each file In fileS
file.getAttribute("name") = "Awpform" Then
file.Click
End If
Next file


Application.Wait DateAdd("s", 4, Now)
enter image description here
       strFileVB = "E:\Upload\Upload.vbs" 


strUploadFile = "E:\Data\2021\test.xlsx"

Shell "Wscript.exe " & strFileVB & " " & strUploadFile 'Here I tried to Run VB

Application.Wait DateAdd("s", 1, Now)
以下是 Upload.vbs 中的代码:
Set WshShell = CreateObject("WScript.Shell")
Do
ret = WshShell.AppActivate("Choose File to Upload")
If ret = True Then
WScript.Sleep 700

dim wsh
Set Wsh = CreateObject("WScript.Shell")

Wsh.Run "cmd.exe /c echo " & WScript.Arguments(0) & "| clip", 0, True 'think I have Error at this line
WScript.Sleep 500
Wsh.SendKeys "{TAB}"

Wsh.SendKeys "{TAB}"

Wsh.SendKeys "^{v}"

Wsh.SendKeys "{TAB}"

Wsh.SendKeys "{TAB}"

WScript.Sleep 700

Wsh.SendKeys "{ENTER}"
End If

Loop Until ret = True
set Wsh = nothing
任何帮助将不胜感激。谢谢

最佳答案

我相信您需要使用 cscript 而不是 wscript。
如果您更新,您是否显示任何更改

Shell "Wscript.exe " & strFileVB & " " & strUploadFile 'Here I tried to Run VB
到以下?
Shell "Cscript.exe " & strFileVB & " " & strUploadFile
https://ss64.com/vb/arguments.html

关于excel - 如何在 vba Excel 中自动上传文件 "Choose File To Upload",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66170099/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com