Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am having trouble saving an Excel spreadsheet.
I copied the code from application to another.
I also copied the way the template spreadsheet is accessed.
I use this to give standard cell headings etc.
In the first application I do not have any problems at all.
In the second application I get a Microsoft Excel diagnostic box that says
Do you want to save the changes you made to spreadsheet_file_name.
If I say yes, the spreadsheet is saved as I want it to be.
However I do not want my user to have to do that!
The code extract is below:
$excel->{DisplayAlerts}=0; $excel_res = 1; $excel->Workbooks(1)->SaveAs($new_spreadsheet) or ($excel_res = 0, $e +w_message = "Could not save spreadsheet"); $en_num = Win32::GetLastError(); $en_err = "message <" . Win32::FormatMessage($en_num) . "> number <" . + $en_num . ">"; $ew_message = "<" . $ew_message . "> is just after saving part file\n" + . "system error text <$en_err>\n"; print "$ew_message\n"; $excel->{DisplayAlerts}=1;
The print gives me

<Could not save spreadsheet> is just after saving part file system error text <message <> number <317>>

Has any monk, wiser than I, a clue as to what is going wrong?

Replies are listed 'Best First'.
Re: Spreadsheet Saving Error
by planetscape (Chancellor) on Jun 30, 2006 at 16:47 UTC

    The equivalent in VBA to the statement you are looking for is:

    Application.DisplayAlerts = FALSE

    Set to false before executing code for which you want to skip confirmations. It's a good idea to set it back to true when you are done. :-)

    BTW, for anyone wondering, the same basic idea in MS Access is called "SetWarnings".

    HTH,

    planetscape