Announcements
Hello Experts,
How can we do Saveas() a Excel file Directly without displaying confirmation message (by Writing Code-unit).
Thank you.
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
Thanks for Your Replay,
Actually I am Unprotecting the Excel file & Saving that file in same path. The code is like below.
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.
As you said , I modified code as like below(added code for Deleting existing file from local system).
But while running this code I am getting error , below.
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.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
OussamaSabbouh 2,371 Super User 2026 Season 1
YUN ZHU 1,806 Super User 2026 Season 1
AndrewThomas81 1,371