Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Asking for saving the document, I don't want that it ask for this??

by nicholas (Novice)
on Apr 16, 2004 at 11:02 UTC ( [id://345714]=perlquestion: print w/replies, xml ) Need Help??

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

Here is the code which I am using
my ($File, $Doc_dir); $Doc_dir = "C:\\word_files"; opendir(TEMP,$Doc_dir); while ($File = readdir(TEMP)) { unless ($File eq "." or $File eq "..") { my $f_check = substr($File,0,2); unless ($f_check eq '~$') { my $Full_File = "$Doc_dir\\$File"; my $f_name = substr($File,0,((length($File))-4)); my $Word = Win32::OLE->new( 'Word.Application', 'Quit' ) | +| die "Couldn't run Word"; my $Doc = $Word->Documents->Open($Full_File) || die "File +does not exist or can not be opened"; # Text information my $num_pages = $Doc->ComputeStatistics(wdStatisticPa +ges); my $num_paragraphs = $Doc->ComputeStatistics(wdStatisticPa +ragraphs); my $num_lines = $Doc->ComputeStatistics(wdStatisticLi +nes); my $num_words = $Doc->ComputeStatistics(wdStatisticWo +rds); my $num_chars = $Doc->ComputeStatistics(wdStatisticCh +aracters); my $num_charWs = $Doc->ComputeStatistics(wdStatisticCh +aractersWithSpaces); my $header = $Doc->Sections(1)->Headers(wdHeaderFooterPrim +ary); my $h_num_pages = $header->Range->ComputeStatistics(w +dStatisticPages); my $h_num_paragraphs = $header->Range->ComputeStatistics(w +dStatisticParagraphs); my $h_num_lines = $header->Range->ComputeStatistics(w +dStatisticLines); my $h_num_words = $header->Range->ComputeStatistics(w +dStatisticWords); my $h_num_chars = $header->Range->ComputeStatistics(w +dStatisticCharacters); my $h_num_charWs = $header->Range->ComputeStatistics(w +dStatisticCharactersWithSpaces); my $footer = $Doc->Sections(1)->Footers(wdHeaderFooterPrim +ary); my $f_num_pages = $footer->Range->ComputeStatistics(w +dStatisticPages); my $f_num_paragraphs = $footer->Range->ComputeStatistics(w +dStatisticParagraphs); my $f_num_lines = $footer->Range->ComputeStatistics(w +dStatisticLines); my $f_num_words = $footer->Range->ComputeStatistics(w +dStatisticWords); my $f_num_chars = $footer->Range->ComputeStatistics(w +dStatisticCharacters); my $f_num_charWs = $footer->Range->ComputeStatistics(w +dStatisticCharactersWithSpaces); #$Word->Activedocument->Close (0); #$Doc->{Saved} = 0; #$Doc->Close(0); my $sys_com = "del $Full_File"; system ($sys_com); } } } close(TEMP); $dbh->disconnect;
  • Comment on Asking for saving the document, I don't want that it ask for this??
  • Download Code

Replies are listed 'Best First'.
Re: Asking for saving the document, I don't want that it ask for this??
by TwistedGreen (Sexton) on Apr 16, 2004 at 13:01 UTC
    While you should really make your question clearer in the post, I've done some work with scripting Excel so I know that asking for confirmation to save is controlled by the Application.DisplayAlerts property. If you set that to false, Excel (and Word) should save the file with default values.

    Hopefully that will solve your problem. However, this isn't really a Perl problem. MSDN is quite handy for these types of queries, and you should probably use that instead. Familiarize yourself with the Word Object Model.

    Good luck.
    ---
    640k is enough for anybody.
Re: Asking for saving the document, I don't want that it ask for this??
by halley (Prior) on Apr 16, 2004 at 14:07 UTC
    This isn't a perl question. You want to tell Word to clear the "modified" flag on the current document. The "modified" flag determines whether Word will ask to save the document before closing it. Search the Word automation documentation for how to do that.

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

Re: Asking for saving the document, I don't want that it ask for this??
by Aragorn (Curate) on Apr 16, 2004 at 11:41 UTC
    I'm not a Windows Perl developer, but maybe you can say something like $Word->Activedocument->Save() or somesuch before closing it.

    Arjen

      I tried almost all which was suggested, but I didn't get succeed on this. More suggestion will be appretiated. Thanks Nicholas
Re: Asking for saving the document, I don't want that it ask for this??
by Abigail-II (Bishop) on Apr 16, 2004 at 11:21 UTC
    Here is the code which I am using
    Yes, and?

    Abigail

      This code is asking for me to save the document or not. I wanted that it should not ask for saving. Just do the process what I assigned to it and quit after iteration ends. Thanks Nicholas

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2025-01-20 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (59 votes). Check out past polls.