0

我正在尝试在 chrome 上自动上传文件,此处出现错误:方法运行对象 iwshshell3 失败”请帮助:

Dim Customer_rates As String

Dim WshShell As Object

Customer_rates = "D:\FX Exch. Rates\2022-Feb-24 1707\MP_customer_exchange_rates_sample.xlsx"

Set WshShell = CreateObject("WScript.Shell")
  
    WshShell.Run "cmd.exe/c echo" & Customer_rates & "| clip", vbNormal, True
    WshShell.SendKeys "^{v}"
    Application.Wait DateAdd("S", 2, Now)
    WshShell.SendKeys "{ENTER}"
4

2 回答 2

0

谢谢伙计们,我用这个子做了一个 cmd 的解决方法,它似乎可以工作:

Sub StoreData() Dim varText As String Dim objCP As Object varText = "D:\FX Exch. Rates\2022-Feb-24 1707\MP_customer_exchange_rates_sample.xlsx" Set objCP = CreateObject("HtmlFile") objCP.ParentWindow.ClipboardData.SetData "text", varText End Sub

于 2022-03-01T10:36:16.297 回答
0

想想这将如何出现在控制台中。文件路径有空格。因此,当您运行它时,它将需要引号。就像是:

WshShell.Run "cmd.exe/c echo" & chr(34) & Customer_rates & chr(34) & "| clip", vbNormal, True
于 2022-02-25T11:28:18.247 回答