esr has asked for the wisdom of the Perl Monks concerning the following question:
However I discovered that some editing operations cause the "Count" property value to increase temporarily. For example, if I highlight a section of text and then select the "Format" menu in Word, the value of $mycnt increases from 1 to 2 and remains there until I finish with any format changes and click "OK". At that point $mycnt returns to its earlier value of 1.# If Word is closed instead of the file, calling "Count" # causes an error message but lowering the Warn level # eliminates it. $mydocnt = $word->Documents->Count(); $word->{Visible} = 1; $word->{WindowState} = wdWindowStateMaximize; $warnlevel = $Win32::OLE::Warn; $Win32::OLE::Warn=1; Win32::MsgBox("After printing, close the file\.",vbOKOnly); $done = 0; while ($done == 0) { if ($word->Documents) { if (($mycnt = $word->Documents->Count()) != $mydocnt) { $done = 1; } } else { undef $word; $word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application'); $done = 1; } sleep 5; }
and that seems to do what I want but I am concerned that I may have problems later, under other circumstances, because I do not understand what is happening here. Perhaps this is more of a Win32::OLE or VBA question but ....if (($mycnt = $word->Documents->Count()) < $mydocnt) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Word Documents->Count in Win32
by Zero_Flop (Pilgrim) on Jan 07, 2005 at 07:37 UTC | |
|
Re: Word Documents->Count in Win32
by jplindstrom (Monsignor) on Jan 07, 2005 at 14:16 UTC | |
by esr (Scribe) on Jan 08, 2005 at 01:09 UTC | |
by jplindstrom (Monsignor) on Jan 08, 2005 at 02:21 UTC |