Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This may be a silly question, but d

Status
Not open for further replies.

scottydd

IS-IT--Management
Sep 19, 2002
31
US
This may be a silly question, but do you need to have Microsoft Word installed on a IIS server to use COMs in PHP? If not how do you access COMs? I've tried:

$word = new COM("word.application") or die("Unable to instanciate Word");

and I get:

Warning: (null)(): Invalid ProgID, GUID string, or Moniker: Invalid syntax in C:\Inetpub\ on line 9
Unable to instanciate Word

Any thoughts?
Scott
 
yes, whatever ms office app that you want to access with COM needs to be installed on the server

Bastien

cat, the other other white meat
 
Can you put Word Viewer, or does it have to be a full version of Word?
 
OK, I put a full version of Word on my Server and i can get PHP to start and quit an application, but it won't open a file. I get the following error:

Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft Word Description: This file could not be found. Try one or more of the following: * Check the spelling of the name of the document. * Try a different file name. (C: est.doc) in C:\Inetpub\ on line 18

Now one thing i did notice is the "(C: est.doc)", this is not what i have coded. I put in the following:

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

Do i something configured wrong or what?

Thanks for any help...
Scott
 
If com won't go for the forward slashes (it should) you can alternately use the double backslash (\\), I've had to do this for certain commands on Win32

-Rob
 
Ok, that helped, but now i get the following error:

Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft Word Description: Could not open macro storage. in C:\Inetpub\ on line 16


Any thoughts?
Thanks
Scott
 
Of course, it could also be that what you are attempting to do is a generally bad idea.

This Mi¢ro$oft Knowledge Base article ( states:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when run in this environment.

[Their boldface, not mine]

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I wouldn't trust the \ inside single quotes, because I think it'll just be used to escape whatever comes next. Not 100% on this, but for example
Code:
$some_string = 'This is Rob\'s String';

Translates to This is Rob's String, I'm guessing putting a \ before the R, would just uselessly escape the R. I know that's how it works in regex's for example.

-Rob
 
PHP handles regular expressions differently than everyday strings. For example, inside a single-quoted string literal, the only backslash-escape string that means anything is \'. Everything else is not interpreted.

For example,
Code:
print "\n";
will print a new line. However,
Code:
print '\n';
will print the literal string \n (backslash n)

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I know this is real basic, but this is the script that i am trying to run...the line that is getting the error is the Documents->Open line...

<html>
<head>
</head>
<body>

<?php

// create an object instance
$word = new COM(&quot;Word.Application&quot;) or die(&quot;Word could not be
started&quot;);

// pop open the Word application
$word->Visible = 1;

// open document
$word->Documents->Open (&quot;c:/test.doc&quot;);

// close the application
$word->Quit();

$word = null;

?>



</body>
</html>
 
Of that I have no doubt. As I have posted earlier in this thread, Mi&cent;ro$oft themselves have stated this is not a good thing to do -- Word was not designed to be operated except in a user-driven GUI environment.

Read the Knowledge Base article, the link to which I have posted. There are some workarounds in there. Although the workarounds are for using COM from ASP, the advice should apply to PHP as well.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top