473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Unusual behaviour opening Word document

If I do not have the indicated Word document open (on my Win XP Pro
machine with PHP 5.2), the following will open and display it:

<?php
$path = "c:\\path\\to\\word\\document\\mydoc.doc";
$doc = new COM($path);
$doc->Application->visible = true;
?>

However, there will be several identical warnings (14 in number)
associated with line 3 (the new COM line):

Warning: com::com(): Type library constant emptyenum is already defined
in C:\test.php on line 3

Am I getting lucky that the doc is opened at all (and hence the
warnings are not bugs), or should this behaviour be reported? This
type of functionality works fine in vbscript:

Path = "c:\path\to\word\document\mydoc.doc"
Set doc = CreateObject(Path)
doc.Application.visible = true

Thanks,
Csaba Gabor from Vienna

PS. Note that if the doc is already opened, the above scripts fail.

Jul 24 '06 #1
3 4855
Csaba Gabor wrote:
If I do not have the indicated Word document open (on my Win XP Pro
machine with PHP 5.2), the following will open and display it:

<?php
$path = "c:\\path\\to\\word\\document\\mydoc.doc";
$doc = new COM($path);
$doc->Application->visible = true;
?>

However, there will be several identical warnings (14 in number)
associated with line 3 (the new COM line):

Warning: com::com(): Type library constant emptyenum is already defined
in C:\test.php on line 3

Am I getting lucky that the doc is opened at all (and hence the
warnings are not bugs), or should this behaviour be reported? This
type of functionality works fine in vbscript:

Path = "c:\path\to\word\document\mydoc.doc"
Set doc = CreateObject(Path)
doc.Application.visible = true

Thanks,
Csaba Gabor from Vienna

PS. Note that if the doc is already opened, the above scripts fail.
OK, this doesn't have anything to do with the specific document. It
also happens if you just do:
$word = new COM("Word.Application");
Initial indications are that the following will suppress the warnings:

$c_artext = "com.autoregister_typelib";
if ($c_ar_t=ini_get($c_artext)) ini_set($c_artext,0);
....
$word = new COM("Word.Application");
....
if ($c_ar_t) ini_set($c_artext, $c_ar_t);

Jul 24 '06 #2
*** Csaba Gabor escribió/wrote (24 Jul 2006 05:27:59 -0700):
<?php
$path = "c:\\path\\to\\word\\document\\mydoc.doc";
$doc = new COM($path);
$doc->Application->visible = true;
?>
According to PHP manual, COM constructor doesn't expect a file name:

com COM::COM ( string module_name [, mixed server_name [, int codepage [,
string typelib]]] )

module_name
Can be a ProgID, Class ID or Moniker that names the component to load.

A ProgID is typically the application or DLL name, followed by a period,
followed by the object name. e.g: Word.Application.

A Class ID is the UUID that uniquely identifies a given class.

A Moniker is a special form of naming, similar in concept to a URL scheme,
that identifies a resource and specifies how it should be loaded. As an
example, you could load up Word and get an object representing a word
document by specifying the full path to the word document as the module
name, or you can use LDAP: as a moniker to use the ADSI interface to LDAP.

In my computer, the code just crashes PHP interpreter.
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Jul 24 '06 #3
Alvaro G. Vicario wrote:
*** Csaba Gabor escribió/wrote (24 Jul 2006 05:27:59 -0700):
<?php
$path = "c:\\path\\to\\word\\document\\mydoc.doc";
$doc = new COM($path);
$doc->Application->visible = true;
?>

According to PHP manual, COM constructor doesn't expect a file name:
That's why I posted. It wasn't entirely clear to me whether my
construct was legal under PHP. But, if you read my subsequent post,
you saw that that was not what the errors were due to.
....
In my computer, the code just crashes PHP interpreter.
The code I gave was for PHP 5.2 on Win XP Pro (and Word 2003).
The calls with COM code are significantly different for PHP 5 vs. PHP
4.

What machine/PHP/Word are you using?
Csaba

Jul 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sivaraman.S | last post by:
Issue: When I am opening a word document or a template from an ASP.NET Web page (language used VB.NET Visual Studio Version 2003) using Word.ApplicationClass object (Reference Word 11.0 object...
1
by: Andy Davis | last post by:
Hi I've written the following code for a button on a form to open a mail merge document in MS Word. The code opens the document fine but does not display the usual connection details to open the...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
0
by: Sivaraman.S | last post by:
Issue : When I am trying to open a Word Document or a Template from a Web Application (ASP.NET Web page - Language Used VB.NET Visual Studio Version 2003) using Word.ApplicationClass (Refering...
1
by: ourspt | last post by:
Hi, We are working on an ASP.NET (VB.NET) application and we have a problem opening a word document from our application. When we try to open the word document, we do not get any error...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
5
by: Cedric | last post by:
Hi Folks, I'm wondering if someone has already succeed to open a word2000 document located on server side with javascript code executed by a web browser on client side. In fact, i make it...
0
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I am creating a webpage and opening it as a Word document. Problem is that as I create one of the questions, some of the text is not appearing in the document as it should. As I step through it, I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.