rootstock has asked for the wisdom of the Perl Monks concerning the following question:

i want to get the text in a doc file which located at Tables(1) Columns(1) and Row(1), after i ran error displayed as following
Win32::OLE(0.1403) error 0x80020003: "" in METHOD/PROPERTYGET "Text" at word1.pl line 10
here is my scrip:
use Win32::OLE; # Object Linking and Embed use Win32::OLE::Const 'Microsoft Word'; # Defines constants word k use Win32::Process ; # Launch a Windows program $Win32::OLE::Warn = 3; # Die on Errors my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit'); $Word->{'Visible'} = 1; my $infile = <d:\\word\\a.doc>; my $Doc = $Word->Documents->Open($infile); my $text = $Word->Selection->Tables(1)->Columns(1)-Row(1)->{Text}; print "printing the text i need\n"; print $text; print Win32::OLE->LastError();
i could not work out this problem, please help.

20030509 Edit by Corion: Added formatting

Replies are listed 'Best First'.
Re: how could i get the exactly text with OLE Word
by jdporter (Paladin) on May 09, 2003 at 12:51 UTC
    If you copy-and-pasted that code (which I hope you did - and if not, shame on you), then you have a serious problem with the critical line. It should look like this:
    $Word->Selection->Tables(1)->Cell(1,1)->Range->Text;
    Besides getting the object model straight (which, I admit, is a very difficult and time-consuming chore), you must also pay attention to your perl syntax. You had
    Columns(1)-Row(1)
    which is clearly not right: it looks like subtraction!

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.

      Yup, that works perfectly!

      Teabag
      Sure there's more than one way, but one only needs one anyway - Teabag

      yes, it works, thank you very much.
Re: how could i get the exactly text with OLE Word
by teabag (Pilgrim) on May 09, 2003 at 12:18 UTC