newbie questions on generating Word document from ColdFusion

Discussion in 'Programming' started by h_c, Sep 28, 2009.

  1. #1
    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 http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000236.htm.


    I looked at the example at http://tutorial13.easycfm.com/ which shows how you can generate a Word document using ColdFusion.

    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 to compile and run it, open a browser and try to open a page http://127.0.0.1:8500/CFIDE/administrator/index.cfm which redirects me to http://127.0.0.1:8500/CFIDE/administrator/index.cfm?target=/CFIDE/administrator/helloworld.cfm?

    I installed the inbuilt web development server which comes with ColdFusion and the server is running. I also installed the JRUN4 as the application I am expected to support, develop used it.

    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.
     
    Last edited: Sep 28, 2009
    h_c, Sep 28, 2009 IP
  2. FCM

    FCM Well-Known Member

    Messages:
    669
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    155
    #2
    @h_c

    I have good news for you. The new ColdFusion CF9 ( Which is Still in Beta ) Has a MS document output and creator built into it. As for the details on how to use it I'm really not quite sure ( I'm still reading the documentation )

    In my experience not everyone has MS Word. PDF is a FREE and effective way to have your product. The PDFS that you create are easily editable, and manageable.
     
    FCM, Sep 29, 2009 IP
  3. Paul_K

    Paul_K Greenhorn

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #3
    Paul_K, Oct 1, 2009 IP