• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Problem reading word file using COM in php

Can no one help with this? I have search all over the internet in messageboards and articles. Everyone seems to just give up on this error. Surely there is someone who knows how to fix it.

PHP Warning: Invoke() failed: Exception occurred. Source: Microsoft Word Description: Could not open macro storage. in c:\inetpub\wwwroot\convert.php on line 18

Here is the code I am using

<?php

// starting word
$word = new COM("word.application") or die("Unable to instanciate Word");

// if you want see the World interface the value must be '1' else '0'
$word->Visible = 1;

//doc file location
$word->Documents->Open("c:\\wwwroot\\trial.doc");

//html file location  '8' mean HTML format
$word->Documents[1]->SaveAs("c:\\wwwroot\\trial.html",8);

//closing word
$word->Quit();

?>

I have checked that the IUSER in security settings is set to interactive.
I have checked for case sensitivity.

All help or even ideas would be greatfully appreciated.
0
flashharry82
Asked:
flashharry82
1 Solution
 
laurlyCommented:
1. make sure word isn't open
2. check the win2k process list because for every time the script crashes you have a winword.exe sitting there.
reason. it opens win word at the beginning of the script if it crashes before it gets to the quit your up a creak.
note: it was actually kind of funny. by the time I realized it I had 30 * winword.exe running.


check this out:
http://www.phpbuilder.com/columns/alain20001003.php3


when i did this i was only createing a new file test this:

<?php
$word=new COM("Word.Application") or die("Cannot start word for you");
print "Loaded word version ($word->Version)\n";

$word->visible =1 ;
$word->Documents->Add();
$word->Selection->Typetext("testing ....");
$word->Documents[1]->SaveAs("c:\web\just_a_test2.doc");
$word->Quit();
print "Done ...........\n";
?>


hope it helps

laurly
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now