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

Announcements

No record found.

News and Announcements icon
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,608 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,947 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,946 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,177 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 555 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans