From: Sylvia on
Hello all,

I'm trying to use my first module (and use perl for the first time in a
number of years, too).

I was able to install the Win32::OLE module, but now I'm not sure how
I'd go about doing 2 things:

1. Opening a word doc file on the web
2. Copying all the text from the word doc file into a variable.

This is what I have right now - it doesn't return errors, but it also
doesn't work. I've tried with both local files and word files on the
internet (which is what I need in the end) but neither works.

**************************************************
use strict;
use Win32::OLE ("with");
use Win32::OLE::Variant;
use Win32::OLE::Const 'Microsoft Word';

my $App = Win32::OLE->new('Word.Application') or
die "Cannot create Word.Application";

#my $files = ("c:\junk\test.doc");

# my @files = ("c:\junk\test.doc");
my @files =
("http://www.cityofbellevue.org/departments/Police/files/Press_2005_08_01_2000.doc");


foreach my $file (@files)
{
my $DocText = $App->Selection;
print $DocText;

}

$App->Quit();


**************************************************

Any thoughts as the direction I should be headed in?

thanks much for any advice!

Sylvia

From: Sylvia on
I got past the error in the code I pasted, but now I'm stuck on another
one. I run this:

******************************************************
use strict;
use Win32::OLE ("with");
use Win32::OLE::Variant;
use Win32::OLE::Const 'Microsoft Word';

my $App = Win32::OLE->new('Word.Application') or
die "Cannot create Word.Application";

my @files =
("http://www.cityofbellevue.org/departments/Police/files/Press_2005_08_01_2000.doc");


my $DocText;
my $MyDoc;

foreach my $file (@files)
{
$MyDoc = $App->Documents->Open($file) ;
$DocText= $MyDoc->Words;

print $DocText;
}
$App->Quit();

******************************************************
My errors are:
1. it comes up with a prompt, that I have to cancel 2 times (when I
access this doc directly from the website,
http://www.cityofbellevue.org/page.asp?view=38806, I don't have this
prompt)
2. The print $DocText doesn't do anything. Am I getting the syntax of
this line wrong?
$DocText= $MyDoc->Words

any help would be much appreciated!!
Sylvia

From: Brian Helterline on
"Sylvia" <Puget4753(a)yahoo.com> wrote in message
news:1124921932.922525.300640(a)g14g2000cwa.googlegroups.com...
>I got past the error in the code I pasted, but now I'm stuck on another
> one. I run this:
>
> ******************************************************
> use strict;
> use Win32::OLE ("with");
> use Win32::OLE::Variant;
> use Win32::OLE::Const 'Microsoft Word';
>
> my $App = Win32::OLE->new('Word.Application') or
> die "Cannot create Word.Application";
>
> my @files =
> ("http://www.cityofbellevue.org/departments/Police/files/Press_2005_08_01_2000.doc");
>
>
> my $DocText;
> my $MyDoc;
>
> foreach my $file (@files)
> {
> $MyDoc = $App->Documents->Open($file) ;
> $DocText= $MyDoc->Words;

This method returns a Words object according to the docs.
If you want to loop over all the words in the document and print them out:

for my $i ( 1 .. $MyDoc->Words->Count )
{
print $MyDoc->Words($i)->Text;
}

--
brian


From: Ron Savage on
On Thu, 25 Aug 2005 07:23:18 +1000, Sylvia wrote:

Hi Sylvia

http://savage.net.au/Perl-tuts-1-30.html

Tuts 16 & 17.


From: Sylvia on
This looks very promising, Ron - thanks for the pointer!
Sylvia

 | 
Pages: 1
Prev: sort
Next: got time out in ftp