任务计划程序运行但未完成或正常工作VBscript
我有一个运行Excelmacros的VBScript。 一切看起来都是正确的,但是它并不像我所希望的那样工作。 任务开始,但只是连续运行,不做任何事情。
让我告诉你我所有的一切…我没有得到任何错误,只是没有正常运行。
任务调度程序时间轴
- 事件110任务由用户触发(任务计划程序为用户“tsee”启动任务“\ Test”的“{6569c7af-fed8-456b-8c8e-9d1653b8c15a}”实例。
- 事件319任务引擎收到消息启动任务
- 事件100任务已启动 – 任务计划程序启动用户“METRO \ tsee”的“\ Test”任务的“{6569c7af-fed8-456b-8c8e-9d1653b8c15a}”实例。
- 事件200操作已启动 – 任务计划程序在任务“\ Test”的实例“{6569c7af-fed8-456b-8c8e-9d1653b8c15a}”中启动了操作“C:\ Users \ tsee \ Desktop \ vbsTest \ runTest.vbs”。
- 事件129创build任务进程 – 任务计划程序启动任务“\ Test”,实例“C:\ Windows \ System32 \ WScript.exe”,进程ID 8964。
之后,它只是说“运行” ,并没有执行任何事情。
我的VBScript:(runTest.vbs)
Dim xlApp Dim xlBook Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open("\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm", 0, True) xlApp.Run "runTaskTest" xlBook.Close xlApp.Quit Set xlBook = Nothing Set xlApp = Nothing
我的Excel表格和macros:(runTask.xlsm)
Sub runTaskTest() Dim erow As Long erow = Cells(Rows.Count, "A").End(xlUp).Row Cells(erow + 1, 1).FormulaR1C1 = "This test was successful : " & Now ThisWorkbook.Save End Sub
任何帮助将非常感激。 提前致谢!
pathnetworking:
继续评论
修改你的VBS文件
Dim xlApp Dim xlBook Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open("\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm", 0, False) xlApp.DisplayAlerts = False xlApp.Visible = False xlApp.Run "runTaskTest" xlBook.Saved = True xlBook.Save xlBook.Close xlApp.Quit Set xlBook = Nothing Set xlApp = Nothing
和你的macros
Sub runTaskTest() Dim erow As Long erow = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row Sheets(1).Cells(erow + 1, 1).Value = "This test was successful : " & Now ThisWorkbook.Saved = True ThisWorkbook.Save End Sub
它应该工作