473,396 Members | 2,081 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.

Msword Com issue

When I run a test code for com object in php I am getting a fatal error of PHP Fatal error: Call to a member function TypeText() on a non-object in C:\inetpub\wwwroot\test.php on line 13. Here is the code I am using
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. // starting word 
  3. $word = new COM("word.application") or die("Unable to instanciate Word"); 
  4. echo "Loaded Word, version {$word->Version}\n"; 
  5.  
  6. //bring it to front 
  7. $word->Visible = 1; 
  8.  
  9. //open an empty document 
  10. $word->Documents->Add(); 
  11.  
  12. //do some weird stuff 
  13. $word->Selection->TypeText("This is a test..."); 
  14. $word->Documents[1]->SaveAs("Useless test.doc"); 
  15.  
  16. //closing word 
  17. $word->Quit(); 
  18.  
  19. //free the object 
  20. $word->Release(); 
  21. $word = null; 
  22.  
  23. header('Content-Type: application/msword'); 
  24. ?>
  25.  
Can someone please help me on this
Feb 20 '12 #1
5 1818
Dormilich
8,658 Expert Mod 8TB
it seems that $word->Selection is not an object. judging from the name, I’m not sure how PHP should select something …
Feb 20 '12 #2
@Dormilich
If I remove the selection and make it
Expand|Select|Wrap|Line Numbers
  1. $word->TypeText("This is a test..."); 
I get PHP Fatal error: Call to undefined method com::TypeText() in C:\inetpub\wwwroot\test.php on line 13
Feb 20 '12 #3
Dormilich
8,658 Expert Mod 8TB
according to tutorials your code should work, so the question is why it fails at that specific point.

first thing to do is enable error reporting and error display, so you know of any warnings PHP issues.
second, double-check all variables and the return values of functions to see if tere is a problem somewhere.
Feb 21 '12 #4
Look forward to finding out more.
Feb 21 '12 #5
It seems the issue overall is for some reason it does not understand typetext(). Is there a php extension I should have added that this is in?
Feb 21 '12 #6

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

Similar topics

0
by: Tom Gao | last post by:
hi guys I'm trying to export an aspx page to msword. ############# I know you can do Response.Clear(); Response.ContentType="application/msword";
1
by: Eilsa | last post by:
I want to perform a full-text search for a lot of MSWord documents. So that I have to read the MSWord content and store it to the database. However, I cannot find any solution on it. What should I...
8
by: Du | last post by:
I'm trying to automate the upload process to yousendit.com, but the file size doesn't add up and yousendit.com keep rejecting my upload (it accepts the upload until the very end) I don't know...
7
by: lkr | last post by:
hi is there is anyway to capture the document events of a MSWord?eg:I have to handle the event awhen WM_KEYUP or anyother events will occur. give me a solution............ thanks in advance lkr
1
by: Jason Huang | last post by:
Hi, I have no problem in creating or modifying a word document in ASP.Net, using C#. However, I don't know how to export database in SQL 2000 or MSAccess to MSWord, given in the ASP.Net and C#...
6
by: Peter | last post by:
I have to write a ASP.NET application that creates MSWord document from a template and populated with data from the webpage. (Templates can reside on the server or client's hard drive.) What is...
1
by: corrigal | last post by:
I am using Visual Studion 2005 with VB and ASP developing a web application. I have automated MSWord to use the spellchecker against a textbox I have on a page. In the V.S. development mode the...
7
by: rinku123 | last post by:
suppose in vb form are more then one textbox which is contain data and i want i click command button it save in msword file and it can replace many times suppose just like we make report). i have...
0
by: arkark | last post by:
Hi I Need Very Urgent In My Project I access the msword, in Msword header section just i insert the text only. I unable to insert the images.how can i insert the image in msword header using asp...
1
by: Matt Curreri | last post by:
I'm trying to automate the creation of a MSWord document with C#; however, when I start creating the MSWord document, I occassionly have a MSWord dialog box displaying a warning of low memory 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: 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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.