how to save excel file for attachment

vijay_gvijay_g Member Posts: 884
hi,
i need to save excel file that has generate by navision report so that i could attach it for sending mail.

Comments

  • BeliasBelias Member Posts: 2,998
    split the problem into 2:
    1. generate an excel file from a report (search mibuso for "excel")
    2. send the file as an attachment (search mibuso for "attachment" and/or "mail")
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • vijay_gvijay_g Member Posts: 884
    Belias wrote:
    split the problem into 2:
    1. generate an excel file from a report (search mibuso for "excel")
    2. send the file as an attachment (search mibuso for "attachment" and/or "mail")

    Thanks a lot.

    i know both task how to do this.
    The problem is how to save excel file automatically(save at defined path like create pdf file and save it automatically ) have been generated from navision report.
  • KarenhKarenh Member Posts: 209
    I have codeunits that are run from NAS, which run reports on a scheduler. In the reports which output to an Excel file, I have a global variable FromScheduler. The codeunit calls a function in the report (which I named SetOptions), which then sets FromScheduler to True.

    I have another global variable in the report PathFileName. That value is set in the SetOptions function. It is passed as a parameter from the calling codeunit.

    In the CreateExcelBook function, I have the following code:

    ExcelBuf.CreateBook;
    ExcelBuf.CreateSheet('Data','',COMPANYNAME,USERID);
    IF CalledfromScheduler THEN BEGIN
    ExcelBuf.SaveWorkBook(PathFileName);
    END ELSE BEGIN
    ExcelBuf.GiveUserControl;
    ERROR('');
    END;

    *********

    I modifed table 370 Excel Buffer to add a function SaveWorkBook, with one parameter which is the PathFileName. The code in the function is:


    XlWrkBk.SaveAs(PathFileName);
    XlWrkBk.Close(FALSE);
    XlApp.Quit;
    CLEAR(XlApp);

    **************

    And Bob's your uncle!
Sign In or Register to comment.