Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Comments for: yunus20031124

Message # 1510112:
Date: 07/08/07 16:31
By: Hans
Subject: Fatal error: com class not defined

Hi there,

I'm struggling with the following error message:

Fatal error: Cannot instantiate non-existent class: com in /cgi-bin/arragon.cfg/scripts/enduser/generate_word_file.php on line 4

I assumed this is a standard class already available, and I haven't read something else on this or other sites.

However, how can I solve this issue?

Below the code I used.

Thanks in advance for any help,
Hans

<?php

header('Content-Type: application/msword');
header("Content-Disposition: attachment; filename=\"Reminder New.doc\"");


//1. Instanciate Word
$word = new COM("word.application") or die("Unable to instantiate Word");
//2. specify the MS Word template document (with Bookmark TODAYDATE inside)
$template_file = "C:/reminder.doc";
//3. open the template document
$word->Documents->Open($template_file);
//4. get the current date MM/DD/YYYY
$current_date = date("m/d/Y");
//5. get the bookmark and create a new MS Word Range (to enable text substitution)
$bookmarkname = "TODAYDATE";
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
//6. now substitute the bookmark with actual value
$range->Text = $current_date;
//7. save the template as a new document (c:/reminder_new.doc)
$new_file = "c:/reminder_new.doc";
$word->Documents[1]->SaveAs($new_file);

//open new file by Hans
readfile($new_file);

//8. free the object
$word->Quit();
$word->Release();
$word = null;
?>

Previous Message | Next Message


Comments:
thank youFra Orv01/27/09 07:39
RE: Inserting Line Breaksbobby.tables10/28/08 07:55
Word on server vs. mime-type tricksSteve09/18/07 10:00
Fatal error: com class not definedHans07/08/07 16:31
how to instantiate COMmienard lumad06/01/07 03:51
write word scriptSandr05/25/07 17:17
Inserting Line BreaksJon01/14/06 08:19
Getting Errorswetha10/28/05 06:13
RE: Pulling out MS Word document propertiesFeierabendbier07/25/05 06:39
create word 2000 filedinanath07/22/05 08:01
Anders Nielsen - RE: A better solution...Object OR .COM07/15/05 17:57
A better solution...Anders Nielsen02/20/05 00:37
RE: No Word on ServerSteven Vanderhoydonks02/08/05 04:32
ideas on parsing Dean01/26/05 12:16
Pulling out MS Word document propertiesRahul01/04/05 19:19
display a word document in html format with pDeepthi Valmikam11/28/04 02:21
generat .doc with tables?anna11/18/04 09:26
RE: Are there other options?Cristian Muraru06/01/04 08:43
RE: Are there other options?tibim03/02/04 15:50
import xhtmlnick02/26/04 17:09
why bother?madis01/04/04 10:40
RE: Are there other options?Mr. Mechano12/30/03 04:51
There is a better RTF-DOC-PDF exampleJon Ritchey12/29/03 14:15
PDF v. WORDsep12/23/03 16:33
RE: Are there other options?Khairul Amri Yunus12/20/03 03:30
RE: Are there other options?Yosh12/13/03 16:05
RE: Word on Server - Not recommended at allAlex12/11/03 16:03
Not as bad as it sounds....andrew taylor12/10/03 06:26
Templates in RTFJeroen Keppens12/09/03 03:42
RE: Are there other options?Eric Esquibel12/08/03 17:42
poor choice..Paul12/06/03 18:46
PDF a better choice for printingDrew F12/05/03 12:05
example using rtf... jon roig12/05/03 11:59
RE: doc poor choice for printingnightowl12/05/03 06:00
RE: Are there other options?nightowl12/05/03 05:58
No Word on ServerMartin Roesch12/04/03 07:38
ex vb programmer?Joe PHP12/03/03 16:28
doc poor choice for printingjohnnyv12/02/03 16:31
Are there other options?Luiz Guilherme12/02/03 14:22
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.