gpt4 book ai didi

excel - 任务计划程序正在运行但未完成或正常工作 VBscript

转载 作者:行者123 更新时间:2023-12-04 20:45:09 31 4
gpt4 key购买 nike

我有一个运行 excel 宏的 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 创建任务进程 - 任务计划程序启动任务“\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 工作表和宏:(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

    任何帮助将非常感激。提前致谢!

    路径网络: enter image description here

    最佳答案

    进一步的评论

    修改你的 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

    和你的宏
    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

    它应该可以工作

    关于excel - 任务计划程序正在运行但未完成或正常工作 VBscript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20220430/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com