Bluehost.com Web Hosting $6.95

Search and Replace with WinWord and COM Objects?

This is a discussion on Search and Replace with WinWord and COM Objects? within the PHP General forums, part of the PHP Programming Forums category; Hey folks... Hopefully, I'm not the only person out there trying this stuff... but I haven't been able ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-01-2003
Jon
 
Posts: n/a
Default Search and Replace with WinWord and COM Objects?

Hey folks...

Hopefully, I'm not the only person out there trying this stuff... but I
haven't been able to find much documentation. I'm trying to do basic
search and replace with Word XP, but am not having any success...

The basics work -- I can connect via com, write some stuff, save a file,
etc... but when it comes to the actual search and replace, it gets ugly.

Here's my sample code:

<?php
$word = new COM("word.application") or die("Unable to instantiate
Word");

print "Loaded word version ($word->Version)\n";
$word->visible = true;
$word->Documents->Add();

$word->Selection->Typetext("This is a test");
$word->Selection->Typetext(" 123");
$word->Selection->Find->ClearFormatting();
$word->Selection->Find->Execute
("test","pain",True,'wdFindContinue',False,False,F alse,False,False,False
);
$word->Documents[1]->SaveAs("c:\wordTest\Useless test5.doc");
?>

Here's the output I get:
Loaded word version (10.0)
Warning: (null)(): Invoke() failed: Exception occurred. Source:
Unavailable Description: Unavailable in C:\Program Files\Apache
Group\Apache2\htdocs\wordFix.php on line 11

Any help would be greatly appreciated...

-- jon

-------------------
jon roig
web developer
email: jon@trafficdesigns.com
phone: 888.230.7557



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.544 / Virus Database: 338 - Release Date: 11/25/2003

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:26 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0