I'd expect to be able to examine those objects with Dumper, but when I do so, I seem to get stuck in a loop and the Windows Task Manager shows the VM Size of my perl.exe pgm getting larger and larger at which point I kill the perl.exe process.
The following sample code extracts the essence of my Dumper test. My question is, "Aren't I able to look at these objects with Dumper?" (The if 0 and if 1 thingies give me easy-to-find debugging hooks to play with.)
(For what it's worth, the original problem I'm investigating is that something new/weird is happening in the Save process. And I don't think I did anything and I'm wondering if something has changed on the OLE side. I can see the Word document being created but when the document is saved to disk, it appears empty. But that's another story....)
use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; use Data::Dumper; # Update: The following line, per advice below, solves my problem: # $Data::Dumper::Maxdepth=2; # check if Word exists my $x = Win32::OLE->GetActiveObject('Word.Application'); die "Word not Installed" if $@; warn "1 OK to here.\n"; # start Word program, die if unable to unless (defined $x) { unless ( $x = Win32::OLE->new('Word.Application', sub { $_[0]->Quit; }) ) { die "Cannot start Word.\n"; } } warn "2 OK to here.\n"; do_dumper( 'wobjX:', $x ) if 1; warn "3 OK to here.\n"; my $template_file = 'e:\\aa\\myfile.dot'; my $d; unless ( $d = $x->Documents->Add( $template_file ) ) { die "Cannot open file '$template_file': $!\n"; } do_dumper( 'wobjD:', $d ) if 0; undef $x; undef $d; warn "4 OK to here.\n"; sub do_dumper { my ( $label, $variable ) = @_; my $msg = Dumper( $variable ); open P2W, ">> p2w_out.txt"; print P2W "$label:\n$msg\n"; #warn "$label:\n$msg\n"; close P2W; }
Update: Made some minor revisions to sample code to fix cosmetic problems with quoting. Thanks for the advice--I'm getting stuff I can read now. :-)
In reply to Win32::OLE Word objects and Dumper by ff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |