"%PROGRAMFILES%\Microsoft Office\Office14\EXCEL.EXE" "C:\Users\user\Documents\MyWorkbook.xlsx"
这对我解决了问题:
32位:
C:\Windows\System32\config\systemprofile\Desktop
64位:
C:\Windows\SysWOW64\config\systemprofile\Desktop
三个重要步骤 - 如何在Task Scheduler中安排excel.xls(m)文件
简单地说:
更详细的解释...
这里是一个.vbs文件的示例:
'
' a .vbs file is just a text file containing visual basic code that has the extension renamed from .txt to .vbs
'Write Excel.xls Sheet's full path here
strPath = "C:\RodsData.xlsm"
'Write the macro name - could try including module name
strMacro = "Update" ' "Sheet1.Macro2"
'Create an Excel instance and set visibility of the instance
Set objApp = CreateObject("Excel.Application")
objApp.Visible = True ' or False
'Open workbook; Run Macro; Save Workbook with changes; Close; Quit Excel
Set wbToRun = objApp.Workbooks.Open(strPath)
objApp.Run strMacro ' wbToRun.Name & "!" & strMacro
wbToRun.Save
wbToRun.Close
objApp.Quit
'Leaves an onscreen message!
MsgBox strPath & " " & strMacro & " macro and .vbs successfully completed!", vbInformation
'
在操作选项卡(任务计划程序)中:
设置程序/脚本:= C:\Windows\System32\cscript.exe
设置添加参数(可选):= C:\MyVbsFile.vbs
最后,不要打开“无论用户是否登录都运行”。
那应该可以了。许多人还需要在他们的机器上创建以下两个文件夹:
32位:
C:\Windows\System32\config\systemprofile\Desktop
64位:
C:\Windows\SysWOW64\config\systemprofile\Desktop
显然,如果Excel不是交互式运行,则需要这些文件夹。即使您使用64位操作系统,也要创建这两个文件夹。
start Excel.exe "C:\Users\User_01\Documentos\file01.xlsm"