I'm not sure if I can attach a file, so here's the code below for
outputting to Word using a template for "Avery Address Labels (#5160)"
I'm thinking about making a Fusebox custom tag of a bunch of Avery
labels. Would anyone make use of this if I made it?
Steve Nelson
<CFPARAM name="attributes.skiplabels" type="string">
<CFPARAM name="attributes.query" type="string">
<CFHEADER name="Content-Disposition" value="attachment;
filename=mailinglabels.doc">
<CFCONTENT type="application/msword">
<HTML xmlns: o="urn:schemas-microsoft-com:office:office" xmlns:
w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<META http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<META name="ProgId" content="Word.Document">
<META name="Generator" content="Microsoft Word 9">
<META name="Originator" content="Microsoft Word 9">
<TITLE></TITLE><!--[if gte mso 9]>
<XML>
<O:DOCUMENTPROPERTIES>
<O:AUTHOR>ColdFusion</O:AUTHOR>
<O:LASTAUTHOR>ColdFusion</O:LASTAUTHOR>
<O:REVISION>1</O:REVISION>
<O:TOTALTIME>0</O:TOTALTIME>
<O:CREATED>#dateformat(now(),"yyyy-mm-dd")#T05:00:00Z</O:CREATED>
<O:LASTSAVED>#dateformat(now(),"yyyy-mm-dd")#T05:00:00Z</O:LASTSAVED>
<O:PAGES></O:PAGES>
<O:WORDS></O:WORDS>
<O:CHARACTERS></O:CHARACTERS>
<O:COMPANY></O:COMPANY>
<O:LINES></O:LINES>
<O:PARAGRAPHS></O:PARAGRAPHS>
<O:CHARACTERSWITHSPACES></O:CHARACTERSWITHSPACES>
<O:VERSION>9.2720</O:VERSION></O:DOCUMENTPROPERTIES></XML>
<![ENDIF]-->
<STYLE><!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:8.5in 11.0in;
margin:.5in 13.6pt 0in 13.6pt;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:4;}
div.Section1
{page:Section1;}
--></STYLE>
</HEAD>
<BODY lang="EN-US" style='tab-interval:.5in'>
<DIV class="Section1">
<TABLE border="0" cellspacing="0" cellpadding="0"
style='border-collapse:collapse;
mso-padding-top-alt:0in;mso-padding-bottom-alt:0in'>
<cfset lastcell=3>
<cfloop from="0" to="#ceiling(attributes.skiplabels/3)#"
index="rowcounter">
<cfif attributes.skiplabels gte val((rowcounter*3)+1)>
<cfset lastcell=1>
<TR style='height:1.0in'>
<TD width="252"
style='width:189.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'></P>
</TD>
<TD width="12" style='width:9.0pt;padding:0in
.75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'><![IF!
supportemptyparas]> <![ENDIF]><O:P></O:P></P>
</TD>
<cfif attributes.skiplabels gte
val((rowcounter*3)+2)>
<cfset lastcell=2>
<TD width="252"
style='width:189.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'></P>
</TD>
<TD width="12"
style='width:9.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'><![IF!
supportemptyparas]> <![ENDIF]><O:P></O:P></P>
</TD>
<cfif attributes.skiplabels gte
val((rowcounter*3)+3)>
<cfset lastcell=3>
<TD width="252"
style='width:189.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'></P>
</TD>
</cfif>
</cfif>
<cfif lastcell is 3>
</TR>
</cfif>
</cfif>
</cfloop>
<cfset thequery=evaluate("caller.#attributes.query#")>
<cfset addresscounter=1>
<cfloop from="1" to="10" index="rowcounter">
<cfoutput>
<cfif lastcell is 3>
<TR style='height:1.0in'>
</cfif>
<cfif addresscounter lte thequery.recordcount and
lastcell is 3>
<TD width="252"
style='width:189.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'>#thequery.first_name[addresscounter]#
#thequery.last_name[addresscounter]#<BR>
<CFIF
len(trim(thequery.address_line_1[addresscounter]))>#thequery.address_line_1[addresscounter]#<BR></CFIF>
<CFIF
len(trim(thequery.address_line_2[addresscounter]))>#thequery.address_line_2[addresscounter]#<BR></CFIF>
#thequery.city[addresscounter]#<CFIF
val(thequery.state_id[addresscounter])>,
#thequery.state_name[addresscounter]#</CFIF>
#thequery.zip[addresscounter]#
<CFIF
thequery.country_name[addresscounter] is not "United
States"><BR>#thequery.country_name[addresscounter]#</CFIF></P>
</TD>
<TD width="12" style='width:9.0pt;padding:0in
.75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'><![IF!
supportemptyparas]> <![ENDIF]><O:P></O:P></P>
</TD>
<cfset addresscounter=addresscounter+1>
</cfif>
<cfif addresscounter lte thequery.recordcount and
(lastcell is 1 or
lastcell is 3)>
<TD width="252"
style='width:189.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'>#thequery.first_name[addresscounter]#
#thequery.last_name[addresscounter]#<BR>
<CFIF
len(trim(thequery.address_line_1[addresscounter]))>#thequery.address_line_1[addresscounter]#<BR></CFIF>
<CFIF
len(trim(thequery.address_line_2[addresscounter]))>#thequery.address_line_2[addresscounter]#<BR></CFIF>
#thequery.city[addresscounter]#<CFIF
val(thequery.state_id[addresscounter])>,
#thequery.state_name[addresscounter]#</CFIF>
#thequery.zip[addresscounter]#
<CFIF
thequery.country_name[addresscounter] is not "United
States"><BR>#thequery.country_name[addresscounter]#</CFIF></P>
</TD>
<TD width="12" style='width:9.0pt;padding:0in
.75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'><![IF!
supportemptyparas]> <![ENDIF]><O:P></O:P></P>
</TD>
<cfset addresscounter=addresscounter+1>
</cfif>
<cfif addresscounter lte thequery.recordcount>
<TD width="252"
style='width:189.0pt;padding:0in .75pt 0in
..75pt;height:1.0in'>
<P class="MsoNormal"
style='margin-top:0in;margin-right:5.3pt;margin-bottom:
0in;margin-left:5.3pt;margin-bottom:.0001pt'>#thequery.first_name[addresscounter]#
#thequery.last_name[addresscounter]#<BR>
<CFIF
len(trim(thequery.address_line_1[addresscounter]))>#thequery.address_line_1[addresscounter]#<BR></CFIF>
<CFIF
len(trim(thequery.address_line_2[addresscounter]))>#thequery.address_line_2[addresscounter]#<BR></CFIF>
#thequery.city[addresscounter]#<CFIF
val(thequery.state_id[addresscounter])>,
#thequery.state_name[addresscounter]#</CFIF>
#thequery.zip[addresscounter]#
<CFIF
thequery.country_name[addresscounter] is not "United
States"><BR>#thequery.country_name[addresscounter]#</CFIF></P>
</TD>
<cfset addresscounter=addresscounter+1>
</cfif>
</TR>
<cfset lastcell="3">
</CFOUTPUT>
</cfloop>
</TABLE>
<P class="MsoNormal"><SPAN style='display:none;mso-hide:all'><![IF!
supportemptyparas]> <![ENDIF]><O:P></O:P></SPAN></P>
</DIV>
</BODY>
</HTML>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists