Solved

HTML2WORD - inserting page numbers

Posted on 2003-11-14
5
604 Views
Last Modified: 2013-12-24
I am producing a word document from generated HTML using the CF tag WORD2HTML.

In developing I first create a WORD doc with word, the middle bit being where the generated data will go.

I then use WORD itself and save as html.

I then chop this html up into two parts - everything up to the data section (header.cfm) and the end which is everything AFTER the data (footer.cfm).

I keep these two files to wrap around the data which I generate as a file (data.cfm)

Then usin g CFFILE I join these 3 files together and use this html file to feed to the CF tag, WORD2HTML to output a WORD file.

So far, so  good. BUT, I want to include page numbers. Has anyone any idea as to how I can do this?









0
Comment
Question by:kjuliff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:anandkp
ID: 9752867
go thru www.cfcomet.com/word & u shld be able to get this done !
0
 
LVL 17

Accepted Solution

by:
anandkp earned 250 total points
ID: 9752880
0
 
LVL 1

Author Comment

by:kjuliff
ID: 9764768
That looks just what I need. I tried to implement but get the error below. I ckech on Macromedia's site and followed the instructions at
http://www.macromedia.com/support/coldfusion/ts/documents/typeviewer_dll_reg.htm
but sill I get this error

The error occurred in D:\htdocs\S+N\fred.cfm: line 80
Called from D:\htdocs\S+N\fred.cfm: line 80
Called from D:\htdocs\S+N\fred.cfm: line 80
 
78 :         <CFOBJECT
79 :             ACTION="create"
80 :             CLASS=" Word.Application"
81 :             NAME="objWord"
82 :             TYPE="com">

 
0
 
LVL 1

Author Comment

by:kjuliff
ID: 9764777
PS I left off the crusial part of the error message
The cause of this exception was that: coldfusion.runtime.com.ComObjectInstantiationException: An exception occurred when instantiating a Com object..
0
 
LVL 1

Author Comment

by:kjuliff
ID: 9765549
OK. I manage to connect to the com object. Burt now I get

The selected method Move was not found.  
There are no methods with the specified method name and argument types. Please check your function and try again.  

With the code from the source suggested above - see

<cftry>    <CFOBJECT
        ACTION="CONNECT"
        CLASS="{000209FF-0000-0000-C000-000000000046}"
        NAME="objWord"
        TYPE="COM">
connect
<CFCATCH>

    <CFOBJECT
        ACTION="CREATE"
        CLASS="{000209FF-0000-0000-C000-000000000046}"
        NAME="objWord"
        TYPE="COM">
create
</CFCATCH>
</CFTRY>


<CFSCRIPT>

    // Open the doc
    objDocs = objWord.Documents;
    objDoc = objDocs.Open("d:\htdocs\s+n\fred.doc ");

// Get the 1st section's 1st footer's range object
    objSecs = objDoc.Sections;
    objSec1 = objSecs.Item(1);
    objSec1Footers = objSec1.Footers;
    objSec1Footer1 = objSec1Footers.Item(1);
    objRange = objSec1Footer1.Range;

    // Set the paragraph format
    // Values for alignment are {0=Left,1=Center,2=Right,3=Justify}
    objParaFormat = objRange.ParagraphFormat;
    objParaFormat.Alignment = 0;

    // Set a right-tab at 6 inches
    // Tab positions are in points, where 72 points = 1 inch
    // Arguments to the TabStops.Add function:
    //    Position: 6 inches * 72 points/inch = 432 points
    //    Alignment: values include {0=Left,1=Center,2=Right}
    objTabStops = objParaFormat.TabStops;
    objTabStops.ClearAll();
    objTabStops.Add(432,2);

    // Insert the page number
    // Page number is field type 33
    // Story is unit type 6
    objRange.Collapse(0);
    objFields = objRange.Fields;
    objFields.Add(objRange,33);
    objFields.Move(6);

    // Insert the footer's text
    objRange.InsertAfter("    Confidential and Proprietary");
    objRange.Collapse(0);
    objRange.Select();
    objSelection = objWord.Selection;
    objSelection.TypeText(Chr(9));
    objSelection.TypeText("Property of XYZ Corp.");


    // Exit
    objDoc.Close();
    objWord.Quit();

</CFSCRIPT>
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question