任务中断:Microsoft Windows 2012R2,任务计划程序,Excel 2013 VBScript

时间:2014-07-15 21:03:31

标签: excel vbscript scheduled-tasks office-automation windows-server-2012-r2

我正在尝试将一些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\

另一个观察

如果我选择任何其他&#34;配置为:&#34;选项,我失去了选择&#34; Windows Server 2003,Windows XP或Windows 2000&#34;共。当我回去编辑任务属性时,该选项就不存在了。任何想法为什么会发生这种情况?

提前致谢。

0 个答案:

没有答案