NAS OLE automation error

kryankerkryanker Member Posts: 14
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

  • ara3nara3n Member Posts: 9,256
    make sure the NAS user has rights to write to the directory where you are saving. Just to test it give NAS user local admin rights.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kryankerkryanker Member Posts: 14
    :? i had already using admin as the NAS user.
  • garakgarak Member Posts: 3,263
    It's running fine also if you run the function on the NAS machine :?: Or comes there the same error?
    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?
    Do you make it right, it works too!
  • kryankerkryanker Member Posts: 14
    It is running fine if I run the function manually on the NAS machine. The error I get is from the Job Queue Log Entries, it appear error on the Log status. :cry:
  • kinekine Member Posts: 12,562
    Where is the NAS installed? Isn't it on Terminal server?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kryankerkryanker Member Posts: 14
    The problem solved...

    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. :?
    IF FILE.EXISTS(FileName+'.xlsx') THEN
      IF ERASE(FileName+'.xlsx') THEN;
    XlWrkBk.SaveCopyAs(FileName+'.xlsx');
    XlWrkBk.Close(FALSE);
    XlApp.Quit;
    CLEAR(XlApp);
    
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'SQL General' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.