Error on Creating an Excel Workbook from Navision

navgirl980navgirl980 Member Posts: 17
Hello everybody,

I am getting the following error on using excel automation. I am trying to save an excel workbook onto a location.

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

Does anyone have any idea how to resolve it? :?:

Comments

  • winfywinfy Member Posts: 8
    Do you use Workbooks.Add or Workbook.Open?

    Code example:

    C/AL Globals (of your MS-Excel Library):
    Name   DataType                   Subtype   
    Excel   Automation   'Microsoft Excel 12.0 Object Library'.Application   
    Book    Automation   'Microsoft Excel 12.0 Object Library'.Workbook   
    Sheet   Automation   'Microsoft Excel 12.0 Object Library'.Worksheet
    
    Create(Excel);
    Book:=Excel.Workbooks.Add;
    Sheet:=Book.Worksheets.Item('Sheet1');
    Sheet.Activate;
    Sheet.Range('A1').Value:='test';
    Book.SaveAs('C:\test.xlsx'); // or an other path
    Book.Close;
    Excel.Quit; 
    CLEAR(Excel);
    

    kind regards,
    winfy
  • navgirl980navgirl980 Member Posts: 17
    Dear Winfy,

    Thanks for ur reply.

    I tried ur code but am having the same error.

    Can you advise

    Thanks
  • navgirl980navgirl980 Member Posts: 17
    Anyone help please
  • vijay_gvijay_g Member Posts: 884
    You need to search this topic on forum(Dynamicusers also) i have seen somewhere else about this topic.
  • imclever1205imclever1205 Member Posts: 94
    I think you should check your path.... This is because you do not have write permission to the specified folder..:wink:
  • navgirl980navgirl980 Member Posts: 17
    U were rite imclever1205.

    In fact,it was not just about the permission issue.If you have a specified a name with invalid characters will give you the same error.

    Thnks
  • sameerarsameerar Member Posts: 63
    Try this ..

    XlWrkBk.SaveAs(FilePath+'\'+FileName,-4143);
    XlWrkBk.Close;
Sign In or Register to comment.