Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: MS Word over Win32::OLE "suddenly" extremely slow

by guha (Priest)
on Aug 25, 2005 at 12:34 UTC ( #486527=note: print w/replies, xml ) Need Help??

in reply to Re: MS Word over Win32::OLE "suddenly" extremely slow
in thread MS Word over Win32::OLE "suddenly" extremely slow

Here is a short example that displays the problem on the new computer

#!perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Const; use Cwd; print "Load Const\n"; my $wdc = Win32::OLE::Const->Load("Microsoft Word") || die "Unable to load constants ", Win32::OLE->LastError(); print "Load Word Engine\n"; my $Word = Win32::OLE->new('Word.Application', 'Quit') || die "Unable to start Word Engine ", Win32::OLE->LastError(); $Word->{'Visible'} = 0 ; $Word->{'DisplayAlerts'} = 0; ## Open template print "Add new doc\n"; my $doc = $Word->Documents->Add() || die"Unable to open new doc ", Win32::OLE->LastError(); # Turnoff background operations $Word->Options->{'Pagination'} = 0; $Word->Options->{'PrintBackground'} = 1; $Word->Options->{'BackgroundSave'} = 0; my $range = $doc->Content; $range->Collapse( {Direction => $wdc->{wdCollapseEnd} } ); my $max_row = 25; my $max_col = 7; print "Creating table $max_row x $max_col\n"; my $t1 = $doc->Tables->Add($range, $max_row, $max_col); my $start = time; print "Start Data Entry\n"; foreach my $row (1 .. $max_row) { foreach my $col (1 .. $max_col) { $t1->Cell($row, $col)->Range->{Text} = "$row-$col"; } } print "Finished Data Entry ", time - $start, " secs\n"; $start = time; print "Start Center\n"; foreach my $row (2 .. $max_row) { foreach my $col (1,3,5.. $max_col) { $t1->Cell( $row, $col )->Range->ParagraphFormat->{'Alignment'} + = $wdc->{'wdAlignParagraphCenter'}; } } print "Finished Center ", time - $start , " secs\n"; my $path = cwd; my $out_file = "$path/word_ole.doc"; $out_file =~ s{\/}{\\}g; $doc->SaveAs($out_file); $doc->Close( { SaveChanges => $wdc->{wdDoNotSaveChanges} } );

I have timed this on three different computers. On the new one it takes around 50 secs to enter data and 70 secs to center data. Whereas on the others enter and center takes around one second each, which is what I was used to.

Replies are listed 'Best First'.
Re^3: MS Word over Win32::OLE "suddenly" extremely slow
by wfsp (Abbot) on Aug 25, 2005 at 12:46 UTC
    ---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" Load Const Load Word Engine Add new doc Creating table 25 x 7 Start Data Entry Finished Data Entry 1 secs Start Center Finished Center 1 secs > Terminated with exit code 0.
    It looks like I'm with the 'others' :-)

    Hope the other replies help you identify what's happening.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://486527]
[LanX]: they were talking about meatspace recently ...
[choroba]: a "thinko"
[erix]: my app (google, really) makes that 1530 km...
[Eily]: google tells me 1662 km ...
[LanX]: Nancy? Somewhere near Metz ...
[Eily]: must be km farenheit or something :P
[Eily]: wow, don't say that in Nancy LanX :P
[erix]: maybe you used the car routes, I used the walking routes
[Eily]: there's a rivalry between the two cities, so defining one in terms of the other might not be well received
[Eily]: erix well I did click on the walking icon

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2017-12-13 15:18 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (369 votes). Check out past polls.