问题描述
正如标题所述,我正在尝试让任务计划程序执行以下操作:
工作簿名称为“每日发票”,并且包含一个宏,因此该文件为xlms。我需要运行的代码在模块1中,因此这是需要选择的代码。
此文件存储在我的文件夹C:\ Users \ MartiJor1 \ Documents \ MACROS \ Daily Invoiced中。
到目前为止,我做了什么? 遵循https://www.thespreadsheetguru.com/blog/how-to-automatically-run-excel-vba-macros-daily中列出的示例,其中计划使用脚本。这是我的结局:
'Input Excel File's Full Path
ExcelFilePath = "C:\Users\MartiJor1\Documents\MACROS\Daily Invoiced ZAMSOTC02 LAC TEAM.xlsm"
'Input Module/Macro name within the Excel File
MacroPath = "Module1.LAC_Daily_Invoiced_Report"
'Create an instance of Excel
Set ExcelApp = CreateObject("Excel.Application")
'Do you want this Excel instance to be visible?
ExcelApp.Visible = True 'or "False"
'Prevent any App Launch Alerts (ie Update External Links)
ExcelApp.displayAlerts = False
'Open Excel File
Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)
'Execute Macro Code
ExcelApp.Run MacroPath
'Save Excel File (if applicable)
wb.Save
'Reset display Alerts Before Closing
ExcelApp.displayAlerts = True
-注意:如果我使用基于Windows的脚本宿主执行脚本,它将平稳运行。
我还使用了本文建议的其余配置来运行脚本,但我使用的是Windows 10 Pro。但是,在计划的时间或手动运行时什么也没有发生。在上次运行结果中,我可以看到代码(0x41303),它是与过去的日期相关的错误代码。不管我在不久的将来对其进行多少次修改,它都不会运行。
我看不到错误。我相信它必须在“动作”选项卡中的某个位置,并且我可以通过上述基于Windows的脚本宿主运行脚本来得出这个结论。有想法的人吗?
这里也是我导出任务时的脚本:
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-10-31T21:41:26.1715916</Date>
<Author>GUWW\MartiJor1</Author>
<Description>Test</Description>
<URI>\DailyInvoiced</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2020-11-02T14:03:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-12-1-4092016482-1174842289-577708437-4023581491</UserId>
<logonType>Password</logonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
<disallowStartIfOnBatteries>false</disallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartondemand>true</AllowStartondemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<disallowStartOnRemoteAppSession>false</disallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WaketoRun>true</WaketoRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT1M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Windows\System32\cscript.exe"</Command>
<Arguments>"C:\Users\MartiJor1\Documents\MACROS\Daily.vbs"</Arguments>
</Exec>
</Actions>
</Task>
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)