Search and Replace with WinWord and COM Objects?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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',Fals
e,False,False,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
 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux