Hello Experts,
How can we do Saveas() a Excel file Directly without displaying confirmation message (by Writing Code-unit).
Thank you.
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;
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.
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.
Thanks for Your Replay,
Actually I am Unprotecting the Excel file & Saving that file in same path. The code is like below.
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
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Andrés Arias as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Sohail Ahmed 2,689 Super User 2025 Season 2
Sumit Singh 2,631
Jeffrey Bulanadi 2,212