Hello anyone,
I had customized a function in NAV5.0 to automate an scheduled reporting email which attached with the excel file generated by the report. I was using NAV standard Excel Buffer table and a customize SaveAs functions to Save the generated excel file. Which was as following function codes and calling:
Function at Excel Buffer table:
SaveExcelFile(FileName : Text[250])
IF FILE.EXISTS(FileName+'.xls') THEN
IF ERASE(FileName+'.xls') THEN;
XlWrkSht.SaveAs(FileName+'.xls');
XlApp.Quit;
Calling at report
Report - OnPostReport()
IF PrinttoExcel THEN BEGIN
TempExcelBuffer.CreateBook;
TempExcelBuffer.CreateSheet('<SheetName>','','',USERID);
TempExcelBuffer.SaveExcelFile(FileName);
END;
It was running fine if I manually trigger this function.
:? But, when I set it as NAS schedule job it always return me an error as below:
This message is for C/AL programmers:
An exception was raised in method SaveAs. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.
even I had tried to re-register the office custom control and restart the NAS, the problem is still there.

:roll:
Any idea what's the problem I facing?
Thank you.
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
did u try to debug the NAS? Can u save in the directory, when u loged in in Windows with the NAS account and work with excel?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I use another Save function from workbook automation instead of worksheet SaveAs function, the NAS job was success. But just the excel file can not save as other format. :?
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!