roho has asked for the wisdom of the Perl Monks concerning the following question:
I am running Strawberry Perl 5.24.1 on Windows 10 with Win32::OLE version 0.1712 (the latest version according to metacpan). This should be very straightforward, but I cannot see what I am missing here. TIA for any suggestions.
#!/usr/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Enum; my $document = Win32::OLE->GetObject("C:\\tmpx\\test.docx") or die " +GetObject failed: $!\n"; my $paragraphs = $document->Paragraphs(); my $enumerate = new Win32::OLE::Enum($paragraphs); while(defined(my $paragraph = $enumerate->Next())) { my $text = $paragraph->{Range}->{Text}; $text =~ s/[\n\r]//g; $text =~ s/\x0b/\n/g; print "$text\n"; }
"It's not how hard you work, it's how much you get done."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE->GetObject Fails on MS Word Document
by davies (Monsignor) on Dec 16, 2020 at 22:39 UTC | |
by roho (Bishop) on Dec 16, 2020 at 22:45 UTC | |
by davies (Monsignor) on Dec 16, 2020 at 22:51 UTC | |
|
Re: Win32::OLE->GetObject Fails on MS Word Document
by GrandFather (Saint) on Dec 16, 2020 at 23:01 UTC |