我有一个 VB 脚本,它打开一个电子表格,执行 RefreshAll 以从外部数据更新工作表,然后 SaveAs a .CSV 我让脚本正常工作,然后移动作业在另一台计算机上运行。该作业正在通过任务计划程序无人值守运行,现在我的错误日志显示 ERROR 424,并且脚本不再更新电子表格,也不再保存 .CSV。该脚本确实以交互方式在这台机器上运行。作业正在使用我的凭据在无人值守的情况下运行。有人对错误 424 有任何帮助吗???
这是代码片段:
dim sLogFile, logFSO, objLogFile
sLogFile = "F:\Feed\FeedLog.log"
Set logFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = logFSO.OpenTextFile(sLogFile, 8, True)
Dim objExcel
Dim objWorkBook, objWorksheet
Set objExcel = CreateObject("EXCEL.APPLICATION")
Set objWorkBook = objExcel.Workbooks.Open("F:\Feed\FeedOlap.xlsx")
Set objWorksheet = objWorkbook.Worksheets("Sheet6")
objLogFile.WriteLine (" " & DATE & " " & TIME & " Starting Refresh")
objworkbook.Refreshall
IF ERR THEN
objLogFile.WriteLine "Error" & Err.Number
End If
objLogFile.WriteLine (" " & DATE & " " & TIME & " Refresh Complete")
objExcel.DisplayAlerts=FALSE
objWorkBook.Save
objWorksheet.SaveAs "F:\Feed\FeedOlapCSV.csv", 6
objWorkBook.Close True
objExcel.Quit
Set objWorkBook = Nothing
Set objExcel = Nothing
objLogFile.WriteLine (" " & DATE & " " & TIME & " CSV Created")