ColdFusion

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentColdFusion

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old September 29th, 2009, 12:02 PM
h_c h_c is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 1 h_c User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 34 sec
Reputation Power: 0
Newbie questions on generating Word document from ColdFusion

I am a complete newbie to ColdFusion and Flex. There was a Flex and Coldfusion developer in our project who left so that work has come to me. My programming background is mainly in C,C++, UNIFACE, PL/SQL with some HTML, JavaScript.

I have a couple of questions and would appreciate if someone could respond to them.

The application I am expected to maintain and enhance prints out reports in PDF format which we need to be in MS-Word format. I have looked at the source for the application and see the below lines in one file

<cfdocument format="pdf" filename="#report_filename_format#" orientation="landscape"
pagetype="legal">

Is there a way to do it in the program so that the output is a MS-Word document? I understand the format attribute can take only "PDF" or "flashpaper" as values as per ColdFusion_Documentation

I looked at the example at easycfm which shows how you can generate a Word document using ColdFusion. I am reproducing the example below

[code starts]
<!--- Try to connect to the Word application object --->
<CFTRY>
<!--- If it exists, connect to it --->
<CFOBJECT
ACTION="CONNECT"
CLASS="Word.Application"
NAME="objWord"
TYPE="COM">
<CFCATCH>
<!--- The object doesn't exist, so create it --->
<CFOBJECT
ACTION="CREATE"
CLASS="Word.Application"
NAME="objWord"
TYPE="COM">
</CFCATCH>
</CFTRY>

<CFSCRIPT>
/* This will open Word if running locally */
objWord.Visible = true;

/* This returns the 'Documents' collection the Word Object */
objDoc = objWord.Documents;

/* Create a new document */
newDoc = objDoc.Add();

/* Save the document to a location */
newDoc.SaveAs("D:\template_new.doc");

/* We specify the range of '0' -- start at the beginning of the document */
docRange = newDoc.Range(0);

/* Add text to the range */
docRange.Text = "Hello World!";

/* Save the changes */
newDoc.Save();

/* Close the document */
newDoc.Close();

/* Quit Word */
objWord.Quit();
</CFSCRIPT>
[code ends]

The first time I ran it it worked well and a word document called Hello.doc was created. The next time, I changed the text to be printed in the Word document from "Hello World" to "Hello World again" it did not and I got the error message "Error Occurred While Processing Request
The SaveAs method was not found. There are no methods with the specified method name and argument types. Check your function and try again.
"

I understand the first time, there was no Word document application object so it was created and the text was written to it properly. The next time, ColdFusion is trying to connect to the Word application object which exists, but somehow it is failing. I changed the name of Word file to be written from Hello.doc to Hello123.doc, but it still did not work. I have permissions to write in the directory where the Word file is being created which is why the example ran fine the first time.

The way I am running this example is typing code in a file called helloworld.cfm which is present in my C:\ColdFusion8\wwwroot\CFIDE\administrator\ directory using Editplus editor, then opening a browser and trying to open a page
localhost:8500/CFIDE/administrator/index.cfm?target=/CFIDE/administrator/helloworld.cfm?

1. Is this the proper method?

2. Can someone please clarify where I might be erring in running this example and how can I fix it?

3. Is there an easier way to get the output from ColdFusion in MS-Word format than what I am doing?

Thanks a lot.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentColdFusion > Newbie questions on generating Word document from ColdFusion


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap