Range property of a Cell is empty and cause script crash

R

Rene Mouchot

Hello,
I'm trying to generate a word file using perl win32::eek:le module and of
course the Word com object.
The word file contain some tables, text, pictures and so on. It work nicely
from the command line but encounter a problem when run via a web access (
asp pages that wrap the perl script).
The script is stopped when it try to set a text of a cell, i found that the
Range property of the cell is not set, which caused the script to crash:

Here's the perl code:
$word->Selection->Tables->Item(1)->Cell(1,1)->Range->{Text} = "Name";

which could be more or less translated in vba to:
ThisDocument.Tables(1).Cell(1, 1).Range.Text = "Name"

Does this Range property emptyness sound familiar to someone ?

Any comments would be greatly appreciated :eek:)
Regards,
 
D

Doug Robbins - Word MVP

There does not appear to be anything wrong with the command as translated
into VBA. Therefore, there must be a problem with the original (and the
accuracy of the translation of course).

Sorry, but the only thing I know about perl has to do with knitting (and I
don't know much about that either - probably not even how to spell it).

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
K

Klaus Linke

Hi Nicolas,

I don't know anything about Perl, either...

Cell.Range.Text has the end-of-cell marker = Chr(13) &Chr(7) at the end.
Perhaps the code falls over because Perl tries to delete/overwrite that, and
can't.
VBA obviously has some work-arounds to avoid this kind of problem.

You could try to change only the text up to the last two characters (using Mid
perhaps).

Regards,
Klaus
 
R

Rene Mouchot

Ok, thanks for your answer. I advance a bit more in the problem resolution.
I found the perl script launch an ole error 0x80010105: "The server threw an
exception". It seems the RPC server ( word i guess ) is shut down during the
script or something like that.
I investigate in google and in msdn but it didn't help much. If i found a
fix, i'll post it here, maybe it could be usefull.


Doug Robbins - Word MVP said:
There does not appear to be anything wrong with the command as translated
into VBA. Therefore, there must be a problem with the original (and the
accuracy of the translation of course).

Sorry, but the only thing I know about perl has to do with knitting (and I
don't know much about that either - probably not even how to spell it).

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top