0

我正在尝试将一些 Excel 自动化任务(任务计划程序)从旧的(Win2003)服务器移动到新的 Windows 2012 R2 服务器。

当我第一次创建任务时,我可以让它工作,但如果我改变任何东西,它就会停止工作,我不知道为什么,或者如何阻止它改变。有什么想法吗?(另见下面我的第二个观察)

这是发生了什么

我创建了如下所示的初始任务,它工作正常,但是如果我更改脚本运行的用户,它会失败并出现错误:

Cannot run the macro 'Build'. The macro may not be available in this workbook or all macros may be disabled.

将任务更改为以原始(工作)用户身份运行并不能修复它。当我重新运行任务并且必须删除/重新创建它才能让它再次运行时,我得到了同样的错误。

文件/任务详细信息

D:\ApplicationDir\run.wsf(简体)

<job id="1">
<script language="VBScript">
  On Error Resume Next
  Dim excel
  Dim SourceFile 
  Set excel = CreateObject("Excel.Application")
  SourceFile = "D:\ApplicationDir\File.xlsm"
  excel.Workbooks.Open SourceFile
  excel.Run "Build"
  excel.Workbooks.Close
  If Err <> 0 Then 
     ... write Err.Description to file ...
  End If
  Set excel = Nothing
</script>
</job>

任务(在任务计划程序中)

 - Runs as a user Account
 - Run whether user is logged on or not
 - Run with highest privileges
 - Configure For: Windows Server 2003, Windows XP or Windows 2000

Triggers:

 - Daily At 6:15 AM every day

Actions:

 - Start a Program:
 - Program: C:\Windows\System32\cscript.exe
 - Arguments: run.wsf
 - Start In: D:\Application_Dir\

另一个观察

如果我选择任何其他“配置为:”选项,我将无法完全选择“Windows Server 2003、Windows XP 或 Windows 2000”。当我返回编辑任务属性时,该选项不存在。任何想法为什么会发生这种情况?

提前致谢。

4

0 回答 0