Hi Matt,
Thanks so much for the code! I'll try it out at work tomorrow and let
you know how it works!!
Peter Bagnato
-Original Message-
From: Matthew Small [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 9:31 AM
To: CF-Talk
Subject: RE: MS Word/CFOBJECT Help
Importance: High
Here is some actual code that I currently use- it's not pretty, but it
does the job for CF. I'll be happy to try to answer any questions for
you.
Matt Small
cftry
cfobject action=CONNECT
class=Word.Application name=objWord type=COM
cfcatch
cfobject action=CREATE
class=Word.Application name=objWord type=COM
/cfcatch
/cftry
cftry
cfscript
objDoc = objWord.Documents;
newDoc =
objDoc.open(#path_documents#\announcerscoresheet_#form.show#.htm);
po = newDoc.PageSetup;
po.Orientation = 1;
po.TopMargin = 36;
po.BottomMargin = 36;
po.LeftMargin = 36;
po.RightMargin = 36;
objSecs = newDoc.Sections;
objSec1 = objSecs.Item(1);
objSec1Headers =
objSec1.Headers;
objSec1Header1 =
objSec1Headers.Item(1);
objRange = objSec1Header1.Range;
// Set the paragraph format
// Values for alignment are
{0=Left,1=Center,2=Right,3=Justify}
objParaFormat =
objRange.ParagraphFormat;
objParaFormat.Alignment = 2;
// 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);
objRange.Select();
objSelection = objWord.Selection;
objFont = objSelection.Font;
objFont.Name = Arial;
objFont.Size = 10;
// 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);
/cfscript
cflock name=printout type=exclusive
timeout=300
cfscript
switch (form.printer) {
case 1:
{objWord.ActivePrinter = #printer_princess#; break;}
case 2:
{objWord.ActivePrinter = #printer_lana#; break;}
case 3:
{objWord.ActivePrinter = #printer_3#; break;}
case 4:
{objWord.ActivePrinter = #printer_4#; break;}
case 5:
{objWord.ActivePrinter = #printer_5#; break;}}
newDoc.PrintOut();
/cfscript
/cflock
cfscript
newDoc.Close();
/cfscript
cfcatch
cfscript
newDoc.Close();
objWord.Quit