0

I am getting following exception in perl. Also i am now to perl technology. Exception is :

Win32::OLE<0.1709> error 0x800a1423
       in METHOD/PROPERTYGET "Close" at getWordComments.pl line no 350

here is the sample code of getWordComments.pl where exception is comming.
A) Following code for opening the document

#Open the document in MS Word
use Win32::OLE;
{
    no warnings;
    use Win32::OLE::Const 'Microsoft.Word';    # wd  constants
}

$word=Win32::OLE->new('Word.Application');
$word->{Visible} = 1;
$word->{DisplayAlerts} = 0;

$Document=$word->Documents->Open({Filename => $filename, ReadOnly => 1});

B) Then i am reading the comment.
C) Following code for Closing the document.

$Document->{Saved}=1;
$Document->Close;
undef $Document;

#Close Word
$word->Quit;
undef $word;

is this problem with office version? because document is with .docx. its working properly for .doc.

Please help me to solve this issue.


I am reading the comment form the document and saving the document on server. Its working fine for rest of the document with extension *.docx and *.doc

Also can you please provide me like how i can do this in perl.

i want to close the document for 2003 office and 2007 office version.

Does this is Version issue?

Thanks and regards Arvind Porlekar

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
user1338040
  • 39
  • 1
  • 8

1 Answers1

1

Wait! You're opening it ReadOnly and then marking it as Saved?? That right there throws flags in my mental processor.

  • The documentation that I can find seems to indicate that this is an issue regarding saving to a different format. That might account for the it-works-in-one-but-not-the-other case.

  • Also, I've seen indications that this is a COM error. It helps to know something about COM. Likely doc and docx are completely different implementations of the same interface defined by the previous doc logic. And it might be the case that the older implementation (doc) is okay with saying that you want to open it ReadOnly, but then wanting to mark it as saved, while the new implementation has the idea that you really should not do this.

As you can see here, one of the arguments handled is OriginalFormat, and it could be that if you don't specify that argument it defaults to a doc format, which then throws the exception that you are trying to save in a different format without explicit instructions. As well another of the arguments is SaveChanges.

So it could be that you are implicitly telling it to save changes in a default doc format, which works in the the doc format, but complains about trying to save it in a different format in the docx format. (understandably)

Axeman
  • 29,660
  • 2
  • 47
  • 102
  • I am reading the comment form the document and saving the document on server. Its working fine for rest of the document with extension *.docx and *.doc. – user1338040 Apr 17 '12 at 12:30