web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to Saveas() Excel file without asking Do you want to Replace Existing File Message.

(0) ShareShare
ReportReport
Posted on by 245

Hello Experts,

How can we do Saveas() a Excel file Directly without displaying confirmation message (by Writing Code-unit).

Thank you.

I have the same question (0)
  • Suggested answer
    I Gusti Made Ari Profile Picture
    3,600 on at

    Use Outstream , sample code : 

    File.CREATE('C:\YourExcelFile.xls');

    File.CREATEOUTSTREAM(Outstr);

    YourRec.SETFRANGE("FIeld 1",Filter1);

    IF YourRef.FINDFIRST THEN BEGIN

        RecordRef.SETTABLE(YourRec);

        REPORT.SAVEAS(REPORT::"Your Report Name",'',REPORTFORMAT::Excel,OutStr,RecordRef)

    END;

    https://docs.microsoft.com/en-us/dynamics-nav/createoutstream-function--file-

    FIle.CLOSE

  • Manikanta_501 Profile Picture
    245 on at

    Thanks for Your Replay,

    Actually I am Unprotecting the Excel file & Saving that file in same path. The code is like below.

    156.PNG

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    Ideally this Message will only come when you already have a file at that location with the same name so technically this is a correct message, if want to get rid of this message then you need to first check if that file already exist there and if yes then you need to move or delete that file.

  • Manikanta_501 Profile Picture
    245 on at

    As you said , I modified code as like below(added code for Deleting existing file from local system).

    Capture_5F00_3.PNG

    But while running this code I am getting error , below.

    Capture_5F00_4.PNG

  • AlexDen Profile Picture
    90 on at

    Hello,

    Try to use Save() instead of SaveAs().

    Or set DisplayAlerts to False before saving the file:

    ExcelApplicationClass.DisplayAlerts := FALSE;
    ExcelWorkbook.SaveAs();
    ExcelApplicationClass.DisplayAlerts := TRUE;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans