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(); </cfscript> <cfrethrow> </cfcatch> </cftry> Matthew Small IT Supervisor Showstopper National Dance Competitions 3660 Old Kings Hwy Murrells Inlet, SC 29576 843-357-1847 http://www.showstopperonline.com -----Original Message----- From: Peter Bagnato [mailto:[EMAIL PROTECTED]] Sent: Friday, December 06, 2002 9:20 PM To: CF-Talk Subject: MS Word/CFOBJECT Help Hello, Does anyone have any example code or documentation (other than the basic templates found on CFCOMET) that can show me how to create, set footers, margins, etc. in MS Word files using CFOBJECT? Thanks! Peter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.