phpcom problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

phpcom problem

Post by PHP_ColdFusion »

ok when i try to connect to word with php's com i get this error

Warning: com::com() [function.com-com]: Type library constant emptyenum is already defined in F:\Database Program\WEBPROGRAM\com.php on line 3

below is teh code that generated it

Code: Select all

//1. Instanciate wordpad
$wordpad = new COM("word.application") or die("Unable to instantiate word");
//2. specify the MS word template document (with Bookmark TODAYDATE inside)
$template_file = "new.doc";
$word->visible = true;
//3. open the template document
$word->Documents->Open($template_file);
//4. get the current date MM/DD/YYYY
$current_date = date("m/d/Y");
//5. get the bookmark and create a new MS word Range (to enable text substitution)
$word->Selection->TypeText("This is a test"); 
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
//6. now substitute the bookmark with actual value
$range->Text = $current_date;
//7. save the template as a new document (c:/reminder_new.doc)
$new_file = "c:/reminder_new.doc";
$word->Documents[1]->SaveAs($new_file);
//8. free the object
$word->Quit();
$word->Release();
$word = null;
can someone help me figure that out?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is it failing at the "new COM" line? Is Word installed on the server?
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

thanks for the effort feyd but i already figured it out was a simple syntax error. :/
phithe
Forum Newbie
Posts: 1
Joined: Sun Apr 22, 2007 5:11 pm
Location: New Zealand

Post by phithe »

what was the syntax error? I've got the same problem..
Post Reply