Excel 2007 SaveAs Method of Workbook Class Failed

klavinklavin Member Posts: 117
Hey everyone,

I just moved the NAS from one machine to another - installed the same version of Excel 2007. Running on Server 2008 NAV 5.0 SP1.

Before I ran updates, I tried having the NAS Fire off some of the jobs I had setup and been using for quite some time now. In them I am using Excel Buffer to make an excel file and then call my own Function in ExcelBuffer where I pass the Filename and save type.
XlWrkBk.SaveAs(FileName,iTypeCode);        
XlWrkBk.Close();
XlApp.Quit();
iTypeCode = 56 for Excel 2003 file.
I attempted removing this since it was optional - saving it as 2007, and even tried the SaveAsCopy method.

For some reason now, this is the part that isn't making sense to me, When I run the codeunit manually (EDIT: From this server using NAV Cleint) - it works. When the NAS Runs it, I get this in the Job Queue Log Entries:
This message is for C/AL programmers:

The call to member SaveAs failed. Microsoft Office Excel returned the following message:
SaveAs method of Workbook class failed

The NAS Login has permission to everywhere it is writing - there is nothing in the Event Viewer except Microsoft Office Sessions Warning just saying:
ID: 1, Application Name: Microsoft Office Excel, Application Version: 12.0.6524.5003, Microsoft Office Version: 12.0.6425.1000. This session was terminated unexpectedly.

I installed updates, still nothing. Kinda getting stumped. I searched the forums, google and maybe I'm just having a real tired moment today... I know it has to do with the NAS/Login since I can run it... unless Excel is trying to pop up something that is causing it to fail...

Anyone see anything like this? ](*,)
-Lavin
"Profanity is the one language all programmers know best."

Comments

  • kinekine Member Posts: 12,562
    1) Have you tried to run the NAS from console?
    2) Have you tried to run the NAS as service under your account?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WogWog Member Posts: 13
    Have you found solution for this? I'm experiencing the same problem.
    I am logged as administrator. When I run the process manually from NAV client, everything works fine.
    When it is processed on nas (under the same user) it ends with the error described in first post.
  • kinekine Member Posts: 12,562
    Is there some dialog opened during the SaveAs when you are running it from client? I assume not, but I want to be sure...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • klavinklavin Member Posts: 117
    To be honest I never did resolve the issue as it was... I did end up writing a new office open xml codeunit and tables (buffer table with style id and worksheet id with cell data etc..., worksheet table holding worksheet id/name, and styles table holding the different styles). Temporarily I did end up just letting this process run under the old server and same account until I completed the office open xml stuff.

    Mind you what I wrote wasn't a complete office open xml solution (if it was I would share it) it completed everything I needed and makes saving .xls files (in xml) and being able to email them SIGNIFICANTLY faster using the same methods of AddColumn etc that Excel Buffer offered. Only difference is users have to open the file opposed to it being automatically opened.
    -Lavin
    "Profanity is the one language all programmers know best."
  • ara3nara3n Member Posts: 9,255
    I ran into this today when running under NAS and the following post solved this.

    http://social.msdn.microsoft.com/Forums ... 421818ef91


    I had to create the Desktop folder on windows 2008 64 bit server as they mentioned and it started working under NAS.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • BorisKBorisK Member Posts: 45
    Adding Desktop folder worked for me as well - after 2 days of banging my head against the wall... This is the most obscure kind of a solution I've ever come across.
  • Sayan81Sayan81 Member Posts: 10
    Hi,
    Thanks for this wonderful trick. Unfortunately even after creating this desktop folder, still I am getting same error.
    Actually I have two server ( in two separate country ). In one server , NAS is running under a service account and I created the desktop folder and after that it worked absolutely fine.
    In other server, NAS is running under a user account ( and that user account has been granted to log on as service ) and here also I created desktop folder and assigned full access to that folder and APPDATA folder for this user account ( rather I gave everyone read/write permission ) and still getting the same error message.
    Am I missing something?

    Thanks in advance.

    Regards,

    Sayan
  • TarcisioTarcisio Member Posts: 1

    try, try, try......


    SaveWkrSpace(FileName : Text[250])
    XlApp.Visible(FALSE);
    //>TB20190516
    //XlWrkSht.SaveAs(FileName);
    //XlWrkBk.SaveAs(FileName);
    XlWrkBk.SaveCopyAs(FileName);
    //<TB20190516
    XlWrkBk.Close(FALSE);
    XlApp.Quit;
    CLEAR(XlApp);
  • gromerrgromerr Member Posts: 2
    I had the same problem on windows server 2012r2 x64

    Although the system is 64 bit, it was necessary to add folders in both locations:
    C:\Windows\SysWOW64\config\systemprofile\Desktop
    C:\Windows\System32\config\systemprofile\Desktop

    after that everything works fine
Sign In or Register to comment.