Word and COM

Posted on 2004-08-18
Last Modified: 2008-02-01

Ok so I tried to mimick the code C# in PHP, came up with the following code:


$word = new COM("Word.Application") or die("Unable to create Word");

$word->Visible = TRUE;

$empty = new VARIANT();


$word->Selection->Find->Text = "Php";

$word->Selection->Find->Replacement->Text = "Hi";




And it does not seem to work. It just times out, can somebody see what I might be missing?
Question by:drakkarnoir
  • 2

Author Comment

ID: 11833456
Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `WdReplace': Unknown name. ' in C:\word.php:25 Stack trace: #0 {main} thrown in C:\word.php on line 25

Accepted Solution

petoskey-001 earned 500 total points
ID: 11838106
I've seen this before.  Try the code from this previous answer and see if it works for you.

Author Comment

ID: 11848761
Going to do this with .NET, thanks guys.

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question