gpt4 book ai didi

未登录时 Excel 不会启动

转载 作者:行者123 更新时间:2023-12-03 00:32:08 25 4
gpt4 key购买 nike

这是我想要实现的事件的顺序:计划任务 - 每天在同一时间运行并启动 VBScriptVBScript 启动 Excel 工作簿并运行宏。这是片段-

Set xlApp = CreateObject ("Excel.Application")
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open (xlFilePath,0,False)
xlApp.Run "Main"

现在的问题是,如果我手动运行该任务,它运行得很好。当我在未登录服务器的情况下运行计划任务时,它不会启动 excel。当没有用户登录时,我必须在上面的代码中更改什么才能启动 Excel?我已将 Excel 宏安全性设置为“低”。

Excel 2003 和 Windows Server2003 64

最佳答案

看看MS Knowledge Base - 据此,Office 应用程序需要 UI 才能运行。

因此,尝试使用除系统用户之外的任何用户:

For example, code that is started by Task Scheduler under the SYSTEM account runs in the same environment as "server-side" ASP code or as DCOM code. Therefore, many of the issues that this article describes may occur.

此外,尝试从 Excel 文件中的 Workbook_Open 事件调用 Main,而不是 xlApp.Run "Main"...

关于未登录时 Excel 不会启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13690069/

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