Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Word and COM

Posted on 2004-08-18
3
Medium Priority
?
400 Views
Last Modified: 2008-02-01
Reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrtskhowtoreplacetext.asp

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

<?php

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

$word->Visible = TRUE;

$empty = new VARIANT();

$word->Application->ChangeFileOpenDirectory("C:\\");
$word->Documents->Open("test.doc");

$word->Selection->Find->ClearFormatting();
$word->Selection->Find->Text = "Php";

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

$word->Selection->Find->Execute(&$empty,
&$empty,&$empty,&$empty,
&$empty,&$empty,&$empty,
&$empty,&$empty,&$empty,
$word->WdReplace->wdReplaceAll,&$empty,&$empty,
&$empty,&$empty);



$word->Quit($empty,$empty,$empty);

?>

And it does not seem to work. It just times out, can somebody see what I might be missing?
0
Comment
Question by:drakkarnoir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:drakkarnoir
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
0
 
LVL 7

Accepted Solution

by:
petoskey-001 earned 2000 total points
ID: 11838106
I've seen this before.  Try the code from this previous answer and see if it works for you.
http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20306226.html
0
 

Author Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

610 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