I am writing a DXL script to export DOORS data to Excel. At the end, I am calling the Excel SaveAs function. If the file already exists, I get a message dialog "Do you want to overwrite this file ?", to which I always reply "Yes". Now, I want to execute the same script in batch mode. So how can I prevent getting this message ?
/*
* This function saves the file as the passed in file name.(From ExcelFunctions.inc)
*/
bool saveFileAs(string filename) {
if(fileOpen) {
clear(args);
put(args, "FileName", filename);
if (excelVersion == "Excel.Application.12") { // If Excel version is 2007
put(args, "FileFormat", "56" ); // Save file as Excel 97-2003 .xls format
}
if(!checkResult(oleMethod(objWorkbook, "SaveAs", args))) {
errorBox("File SaveAs failed.");
return(false);
}
return(true);
}
errorBox("File not open");
return(false);
}
sdauphin - Tue Aug 02 10:15:40 EDT 2011 |
Re: Excel SaveAs Overwrite message ActiveDocument.SaveAs filename:="OLDFILE.docx", FileFormat:= _ wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _ :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _ :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False |
Re: Excel SaveAs Overwrite message for excel Try: Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:= _ "P:\1-1\Book11.xls" Application.DisplayAlerts = True |
Re: Excel SaveAs Overwrite message
Don't know about your dialog problem from Excel; but I'd be tempted to just delete the file in DXL before commanding Excel to save it.
void errorBox_Temp(string Message)
{ print "in 'errorBox_Temp()'\n"
if (batchMode()) //
then print Message "\n"
else errorBox(Message) // Call the standard "errorBox"
} // end errorBox_Temp()
void errorBox(string Message)
{ // Override function of standard "errorBox"
print "in overrride 'errorBox()'\n"
errorBox_Temp(Message)
} // end override errorBox()
errorBox("hello") // debug
|
Re: Excel SaveAs Overwrite message llandale - Tue Aug 02 13:29:33 EDT 2011
Don't know about your dialog problem from Excel; but I'd be tempted to just delete the file in DXL before commanding Excel to save it.
void errorBox_Temp(string Message)
{ print "in 'errorBox_Temp()'\n"
if (batchMode()) //
then print Message "\n"
else errorBox(Message) // Call the standard "errorBox"
} // end errorBox_Temp()
void errorBox(string Message)
{ // Override function of standard "errorBox"
print "in overrride 'errorBox()'\n"
errorBox_Temp(Message)
} // end override errorBox()
errorBox("hello") // debug
|
Re: Excel SaveAs Overwrite message David_G_Bond - Wed Aug 03 10:31:06 EDT 2011
I then write a batchmode wrapper DXL associated with that DXL that "#include" the interactive part. I have special batch mode #include to override all the standard ack/warning/confirm bla bla bla such that the info is stored in a Buffer. The batch wrapper then finishes setting needed DBE values and calls the main interactive "OK" callback which runs the script. When finished, the special batch-mode messages in the buffer are dumped to a text file along with some other cleanup, and the batch wrapper ends. Executable code in the batch wrapper is a paltry 16 lines. Since the main program generally displays a report, in the morning I see two reports, one from the main and the silly one from the batch wrapper, which generally just says "Done OK". The Include line is pretty clever: #include <../Project/Project-Scripts/DBAdmin/Archive_DataBase.dxl> Which presumes that folder "Project" has a sibling folder defined in Addins, in my case folder "Module".
|