Normal Topic Variables and WordMerge (Read 437 times)
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Variables and WordMerge
Dec 9th, 2005 at 10:53pm
Print Post Print Post  
Can the value of a variable be used in a WordMerge/Mail merge?

How?

Thanks
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Variables and WordMerge
Reply #1 - Dec 10th, 2005 at 3:07am
Print Post Print Post  
If you just use export, then you will need to be using elements that are bound.   You can create a bound LE and store the value of the variable in that element.  Then include the element in the export.

If you use File I/O to write your export file then you can include variables.  Define the file to write to. Build the string to be written to the file, and use I/O to write to the file.

The Merge document does not care how the merge data file was created.  It does not know that the delimited data came from an LE or written using variable.

===================================
Here is an excerpt that is based on code provided by Tom Marcellus in an issue of Inside Sesame:
Quote:
while vLoop <= vCount {

     vHeader += "EventDate" + vLoop + "^"
     + "Event" + vLoop + "^"
     + "Fee" + vLoop + "^"
     + "CEU" + vLoop + "^"
     + "RunningTotal" + vLoop + "^"
     + "CPEYears" + vLoop + "^"

     //Note: DO NOT USE "tblName!" in front of "frmName" - No data will result
     vData += @FormFieldValue("sfrmEvents", "EventDate", vLoop) + "^"
     + @FormFieldValue("sfrmEvents", "Event", vLoop) + "^"
     + @ToNumber(@FormFieldValue("sfrmEvents", "Fee", vLoop)) + "^"      
     + @ToNumber(@FormFieldValue("sfrmEvents", "CEU", vLoop)) + "^"
     + @ToNumber(@FormFieldValue("sfrmEvents", "RunningTotal", vLoop)) + "^"      
     + @FormFieldValue("sfrmEvents", "CPEYears", vLoop) + "^"

     vLoop += 1

     }

     // Using "^" as a field delimiter, using EOL as record separator.
     
     FOR n = vLoop to vMaxEvents
           vHeader += "EventDate" + n + "^"
           + "Event" + n + "^"
           + "Fee" + n + "^"
           + "CEU" + n + "^"
           + "RunningTotal" + n + "^"
           + "CPEYears" + n + "^"
           vData += "^^^^^^^"      
     NEXT


// Write header & data lines to the export merge data source file
vFileHandle = fileOpen(vDataPath)
fileSeek(vFileHandle, 0)
fileWriteLn(vFileHandle, vHeader + @NewLine() + vData)
fileClose(vFileHandle)
End SubRoutine
//========================================================

Note that the fileWrite command is only sending out variables.  The LE values have been combined into varialbe vHeader and vData.  In the FOR and WHILE loops that the variables "vLoop" and  "n" are appended to the name of the LE when creating the header lines.  And where the values of the LEs are used, variables could be used there also and/or in addition to the LEs
.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: Variables and WordMerge
Reply #2 - Dec 12th, 2005 at 3:22pm
Print Post Print Post  
Perfect,  that is exactly what I needed. 

Thanks Cheesy
  
Back to top
 
IP Logged