You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编写WSF脚本读取CSV触发Object Required错误,请求排查解决

问题原因及解决方法

你的错误出在错误使用Set关键字给字符串变量赋值。

VBScript里,Set仅用于给对象类型的变量赋值(比如objFSO、objInFile这类对象实例),而strSourcePath、strSourceFile、strData都是普通字符串变量,不能用Set,直接赋值即可。

修正后的代码:

<job id="Test_Script">
   <script language="VBScript">

    Dim objFSO, strSourcePath, strSourceFile, objInFile, strData    

    strSourcePath = "C:\test\ERACSV\"
    strSourceFile = "Payments.csv"
    Set objFSO        = CreateObject("Scripting.FileSystemObject")   
    Set objInFile     = objFSO.OpenTextFile(strSourcePath & strSourceFile, 1, False)
    strData       = objInFile.ReadAll
    objInFile.Close

    WScript.Echo strData
   </script>
</job>

关键修正点:

  • 移除strSourcePath、strSourceFile、strData前的Set关键字
  • 保留objFSO、objInFile前的Set(因为它们是对象变量)

内容的提问来源于stack exchange,提问作者Travis Heeter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 08:37:39