Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

execution of program without dialogue prompting up.

by Mr_monk (Initiate)
on Jan 21, 2008 at 17:36 UTC ( [id://663403]=perlquestion: print w/replies, xml ) Need Help??

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

I'm using win::ole module. The following code is used to create a file new file and save it as .csv. But, when the script is executed there is a dialogue prompted which says "Do Yyou want to save". How do I write a code which does not actually pop up this dialogue. #Excel sheet opening
use Win32;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$file = "d:\\test.csv";
my $Excel = Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{SheetsInNewWorkbook} = 1;
my $Book_Schedule = $Excel->Workbooks->Add;
my $Sheet_Schedule = $Book_Schedule->Worksheets(1);
$Sheet_Schedule->Cells(1,1)->{'Text'} = "Success";
$Book_Schedule->SaveAs("$file");
$Book_Schedule->Close;
  • Comment on execution of program without dialogue prompting up.

Replies are listed 'Best First'.
Re: execution of program without dialogue prompting up.
by nikosv (Deacon) on Jan 21, 2008 at 18:25 UTC
    By using the DisplayAlerts property (Application.DisplayAlerts = False)
    So it should be like :
    $Excel->{DisplayAlerts} = "False" $Book_Schedule->SaveAs("$file"); $Excel->{DisplayAlerts} = "True" $Book_Schedule->Close;
Re: execution of program without dialogue prompting up.
by halley (Prior) on Jan 21, 2008 at 18:22 UTC
    The somewhat... er... "abbreviated" anonymous answer above is likely on the right track.

    Mimic what you'd have to do in the GUI, through Perl. Save your desired copy as a ".csv", and then go through the seemingly pointless exercise of saving a new ".xls" file, and then deleting it after closing. Unless the API gives you a "close and ignore changes" option, this is your best bet.

    --
    [ e d @ h a l l e y . c c ]

Re: execution of program without dialogue prompting up.
by Anonymous Monk on Jan 21, 2008 at 18:18 UTC
    Try Save

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://663403]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found