473,699 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\wor d\document\mydo c.doc"
Set doc = CreateObject(Pa th)
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 4882
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\wor d\document\mydo c.doc"
Set doc = CreateObject(Pa th)
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.Appli cation");
Initial indications are that the following will suppress the warnings:

$c_artext = "com.autoregist er_typelib";
if ($c_ar_t=ini_ge t($c_artext)) ini_set($c_arte xt,0);
....
$word = new COM("Word.Appli cation");
....
if ($c_ar_t) ini_set($c_arte xt, $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.Applicatio n.

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
4008
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 Library), I am getting the following error: could not open macro storage (System.Runtime.comExeception) I am not getting any errors while opening the same word document or a template from a windows application. (Language Used VB.NET)
1
1815
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 table in my database when the file is opened.i.e: "Opening this document will run the following SQL command: SELECT * FROM 'filename' " Hence all that is opened is a document with no updated details from the source table. If I open the document...
3
5583
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 document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
0
4910
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 Word 11.0 Library), I am getting the following Errror: Could not open Macro storage. (System.Runtime.ComExeception) When I am Opening the word document from a Windows Application, It is
1
2155
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 message but the system hangs.
2
3374
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 confirm that I want to run a query to select the data from the data source file, then it opens the form letter fine. I can preview the merged records and complete a merge to a new document. I have a VB 2006 project (.net framework 2.0) which opens the...
5
2564
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 without any problem when the client use Word XP & 2003 but no result with Word 2000. Any suggestions are welcomed,
0
1644
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 can see the text in my string builder variable, but once the page opens as a Word document, that same text is not showing. It seems to only be text that I am displaying as a result of some checkboxes I am trying to write to the page. Can anyone...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.