【问题标题】:Error 800A03EE in my VB script while running through command prompt通过命令提示符运行时,我的 VB 脚本中出现错误 800A03EE
【发布时间】:2019-03-21 11:49:00
【问题描述】:

我在 Windows 上通过命令提示符运行,并在第 24 行和第 34 个字符处收到警报

代码示例如下:

Sub CatchMe()

      Dim outobj, mailobj
      Dim strFileText
      Dim objFileToRead

      Set outobj = CreateObject("Outlook.Application")
      Set mailobj = outobj.CreateItem(0)
      strFileText = GetText("C:\Users\Yatheesh.Sathyanaray.STDC\Documents1.txt")

        With mailobj
        .To = "yatheesh.satyanarayana@stratogent.com"
        .Subject = "Testmail"
        .Body = strFileText
        .Display
      End With

      'Clear the memory
      Set outobj = Nothing
      Set mailobj = Nothing

    End Sub

    Function GetText(sFile As String) As String
       Dim nSourceFile As Integer, sText As String
       nSourceFile = FreeFile
       'Write the entire file to sText
       Open sFile For Input As #nSourceFile
       sText = Input$(LOF(1), 1)
       Close
       GetText = sText
    End Function

【问题讨论】:

  • VBScript 不允许您将变量定义为String 之类的类型,因此您需要删除所有as Integeras String 语句...
  • 整个函数 GetText() 将失败,在 VBScript 中,如果您想读取文件,请使用 Scripting.FileSystemObjectStack Overflow 上有很多示例。

标签: vbscript outlook office365


【解决方案1】:

它可以在我的机器上使用您提供的代码。我已经在 Excel 文件中对其进行了测试,并将您的代码复制如下:

但是,我注意到您使用了一个名为“FreeFile”的属性,使用时没有看起来那样。

【讨论】:

  • “有效” 因为您使用的是 VBA 而不是 VBScript,它们是不一样的。它们可能有相似之处,但也有明显不同,不应互换使用。
猜你喜欢
  • 1970-01-01
  • 2020-09-04
  • 1970-01-01
  • 2015-10-21
  • 1970-01-01
  • 2021-07-07
  • 1970-01-01
  • 1970-01-01
  • 2019-11-13
相关资源
最近更新 更多