Jump to content

Reading Word 2007 Files


Bobro

Recommended Posts

Hello,

 

I'm trying to read some .doc or .docx files or make any contact with word 2007 but so far i'm getting nothing, i tried to get it working even used the example code from php.net but it still refuses to work with word, i don't know why.

 

The example code from php.net

<?php
// starting word
$word = new COM("word.application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";

//bring it to front
$word->Visible = 1;

//open an empty document
$word->Documents->Add();

//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");

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

//free the object
$word = null;
?>

 

Fatal error: Call to undefined method variant::SaveAs()

or

Fatal error: Call to undefined method variant::Quit()

 

Also tried

$content = (string) $word->ActiveDocument->Content;
echo $content;

And various stuff with

$word->ActiveDocument
$word->Documents[1]
$word->Documents[0]
$word->Documents

 

All i'm getting is function not found or an infinite time loop until i kill the word process... :(

Link to comment
https://forums.phpfreaks.com/topic/173459-reading-word-2007-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.