473,396 Members | 1,996 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,396 software developers and data experts.

PHP & COM with MS Office

yayh
3
Dear all

i tried this fine artical which guide you to write php code to create ms office file using COM.


http://web.informbank.com/articles/t...-documents.htm

the problem that all the examples in this guide worked fine except the ms word example i am getting the following error:

this is the output:
I'm using MS Word 11.0
Fatal error: Call to a member function TypeText() on a non-object in C:\Inetpub\temp\index.php on line ...

$word->Selection->TypeText("Hello, universe!"); // error is here !

please help i tried everything...

note: i am using windows server 2003 sbs and php 5 and office 2003


**************************************

ok i have another code which also give error and did know how to solve it

this the error :

Loaded Word, version 11.0
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word
Description: Command failed' in C:\Inetpub\temp\index.php:... Stack trace: #0 C:\Inetpub\temp\index.php(...): variant->Open('C:/inetpub/temp...') #1 {main} thrown in C:\Inetpub\temp\index.php on line ...

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  //1. Instanciate Word
  3. $word = new COM("word.application") or die("Unable to instantiate Word");
  4. print "Loaded Word, version {$word->Version}\n";
  5. //2. specify the MS Word template document (with Bookmark TODAYDATE inside)
  6. $template_file = "C:/Inetpub/temp/reminder.doc";
  7. //3. open the template document
  8. $word->Documents->Open($template_file);
  9. //4. get the current date MM/DD/YYYY
  10. $current_date = date("m/d/Y");
  11. //5. get the bookmark and create a new MS Word Range (to enable text substitution)
  12. $bookmarkname = "TODAYDATE";
  13. $objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
  14. $range = $objBookmark->Range;
  15. //6. now substitute the bookmark with actual value
  16. $range->Text = $current_date;
  17. //7. save the template as a new document (c:/reminder_new.doc)
  18. $new_file = "C:/Inetpub/temp/reminder_new.doc";
  19. $word->Documents[1]->SaveAs($new_file);
  20. //8. free the object
  21. $word->Quit();
  22. $word->Release();
  23. $word = null;
  24.  
  25. ?>
Mar 15 '07 #1
2 2511
yayh
3
helloo help.......!!!
Mar 18 '07 #2
yayh
3
again helloo help ...!!!
Mar 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Ransburg | last post by:
Hello! Is there some library for comparing & merging XML documents? I want it to do something like that: Base document: <office> <desk color="brown" height=50></desk> </office>
1
by: Prasad Patil | last post by:
Hi, I have installed Office 2000 & Office 2003 on my Machine I wish to use excel 2003 in my Dot Net Project When I reference the Microsoft Excel 5.0 Object library the code using Excel...
3
by: solomon_13000 | last post by:
> Wonthaggi Civic Theatre 'WCT' Case Study > > The town of Wonthaggi has a theatre which is owned and > operated by the local council, it is called the > Wonthaggi Civic Theatre (WCT) and a wide...
1
by: Bob N5 | last post by:
I am working on an application that uses interop to do some simple operations with both Excel and Word. I have most of functionality working, but ran into issues on making things work with both...
1
by: meganrobertson22 | last post by:
Hi Everybody- I am trying to create a Table structure to represent the relationship between Agencies and their Sub-Agencies. There are Agencies and Sub-Agencies. Some Agencies have...
1
by: keith | last post by:
(Visual C++.NET) I could be mistaken here, but I can only find examples of how to automate Excel in the form of MFC projects. I have a large managed C++ project which needs to automate excel,...
3
by: D. Kennedy | last post by:
I know that .NET needs atleast Access 2000 for any Access database stuff. But does the framework need all Office 2000 products or more recent. Or can I use for example Excel 2000 to output some...
2
by: Amos Soma | last post by:
We're creating a VS 2005 C# app that needs to integrate with Excel & Office. Can anyone tell me which versions of Excel and Office C#/VS 2005 supports? I'm most interested in knowing how far back...
0
by: salad | last post by:
I took the Bart down to San Francisco and joined a couple thousand other nerds to watch the Vista/Office launch. The receptionist was quite pleasant and getting the event packets a smooth...
0
by: dt | last post by:
I downloaded Microsoft Office 2003 Reference Schemas from: http://www.microsoft.com/downloads/details.aspx?familyid=fe118952-354... Then I tried to use JAXB on them, specifically excel.xsd and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.