Normal Topic Merge Print Datasource file *.txt not found ??? (Read 512 times)
dcostanzo
Junior Member
Members
**
Offline


No personal text

Posts: 58
Joined: Mar 13th, 2003
Merge Print Datasource file *.txt not found ???
Feb 3rd, 2004 at 6:01pm
Print Post Print Post  
Hello Lanticians, members

I have a *.db  set up an element Merge Print. Everything working fine.

Today I went into each word document to clean it up a bit. All I did is align some things better in all the *.docs

Saved all documents.

Now when inside the *.db  searched one record and tried to do a fax cover call TODDFAXCOVER.doc.

An error occours saying word can not find its data source
c:\sesame\docs\esmibids1.txt

I click on find datasource  to c:\sesame\docs\esmibids1.txt.  It just bounces me back to find datasource again???

I check to see if file is there and it is.  Trying  to trouble shoot this???

Test program and no errors.

Can anyone offer any assistance?


Program code under Print Merge element

var vFileHandle as Int          // For writing data file
var vHeader as String           // Data file header line
var vData as String             // Data file data line
var n as Int = 1                                    // General purpose counter
var vSelectedDoc as String      // Document selected from menu
var vOneOrAll as String         // Include record(s) option
var F as array[25] of String    // Mergeable fields array
var vStartingRec = @ResultSetCurrentPosition()
var vGoPrint as String

// Next 3 lines user modifiable
var vDataPath as String = "c:\sesame\docs\esmibids1.txt"
var vDocsPath as String = "c:\sesame\docs\"
var vWordPath as String = "c:\sesame\word.bat"


SUBROUTINE PrintCurrentRecordOnly()

If @Askuser("Merge print the " + vSelectedDoc + " for "
+ vOneOrAll + "?","","") Then
{

vGoPrint = "Yes"

n = 1                  
While F[n] <> ""
{
     vHeader = vHeader + F[n]   + "^"
     vData   = vData   + @(F[n]) + "^"
     n = n + 1
}

vFileHandle = fileOpen(vDataPath)
fileSeek(vFileHandle, 0)
fileWriteLn(vFileHandle, vHeader + @NewLine() + vData)
fileClose(vFileHandle)

}

END SUBROUTINE

SUBROUTINE PrintAllRetrievedRecords()

var n as Int
var i as Int = 1

If @Update Then
{

If @Askuser("Merge Print " + vSelectedDoc + " for these " + @ResultSetTotal() + " retrieved records?",
"( If not, cancel this task, press F7 for a new search,"," and retrieve the records DO you want to print. )")
Then
{

     vGoPrint = "Yes"

     n = 1                  
     While F[n] <> ""
           {
           vHeader = vHeader + F[n]   + "^"
           n = n + 1
           }

     vFileHandle = fileOpen(vDataPath)
     fileSeek(vFileHandle, 0)
     fileWriteLn(vFileHandle, vHeader)

     For n = 1 to @ResultSetTotal()

     ResultSetCurrentPosition(n)

     While F[i] <> ""
           {
           vData = vData + @(F[i]) + "^"
           i = i + 1
           }

     FileWriteLn(vFileHandle, vData)

     @Msg("Processed Record " + n + " of " + @ResultSetTotal())
     vData = ""
     i = 1

     Next

     fileClose(vFileHandle)

     // Rewind to record where it all started
     ResultSetCurrentPosition(vStartingRec)

     }
}
Else
@Msgbox("Printing retrieved records can only be done in Update mode.","","")

END SUBROUTINE


// BEGIN MAIN PROGRAM

// Build documents menu

vSelectedDoc = @PopupMenu(
"NY CONTRACT TD.doc;"   +
"NY CONTRACT D.doc;" +
"CT CONTRACT TD.doc;" +
"CT CONTRACT D.doc;"+
"CT QUOTE.doc;" +
"NY QUOTE.doc;" +
"DISPOSAL ONLY QUOTE.doc;" +
"COAL TAR QUOTE.doc;" +
"COAL TAR CONTRACT.doc;" +
"TODDFAXCOVER.doc;" , "SELECT MERGE DOCUMENT" )

// Build which record(s) menu

vOneOrAll = @PopupMenu(
"THIS Record Only;" +
"ALL Retrieved Records;" , "SELECT RECORD(S) TO MERGE PRINT" )

If vSelectedDoc <> "" and vOneOrAll <> "" Then
{      

     // Delete existing data file. A new one will be generated.
     If FileExists(vDocsPath + vSelectedDoc) Then
     {
     fileDelete(vDataPath)      

     // Fields available for merging
     F[1] = "CUSTOMER NAME0";F[2] = "Address";F[3] = "Address20";
     F[4] = "City0" ;        F[5] = "ST";     F[6] = "zip0" ;
     F[7] = "Fax";F[8] = "Site Name" ;     F[9] = "SAddress";
     F[10]= "SCity";        F[11]= "SST"; F[12]= "SZip";
     F[13]= "TD Price"; F[14]= "Contaminated Soil type0";  F[15]= "Qty Tons Quoted"; F[16]= "Pmt_Term0";
       F[17]= "PHONE"; F[18]= "Other Services"; F[19]= "Title"; F[20]= "contact"; 
       F[21]= "PMT_TERM0"
      
        


     If vOneOrAll = "THIS Record Only" Then
           PrintCurrentRecordOnly()
     Else
           PrintAllRetrievedRecords()

     If vGoPrint = "Yes" Then
     {
           // Start Word via Word.bat and pass doc filename.            
           n = @Shell(vWordPath + " " + @Chr(34) + vDocsPath + vselectedDoc + @Chr(34))
           If n = 1 Then
           @Msgbox(vDocsPath + vSelectedDoc,"word.bat not found or something else wrong.","")
     }
     }
     Else
           @Msgbox(vDocsPath + vSelectedDoc + " doesn't exist.","","Aw shucks!")




}
  
Back to top
 
IP Logged
 
dcostanzo
Junior Member
Members
**
Offline


No personal text

Posts: 58
Joined: Mar 13th, 2003
"Undaunted" problem resolved
Reply #1 - Feb 6th, 2004 at 4:52pm
Print Post Print Post  
Lanticians, members

Sesame/Microsoft Word merge printing system

It appears that I had linked to Microsoft Word the wrong format in creating a  data source file *.txt
Therefore, it did not recognize the datasource file.

The data source file should look exactly like  what is listed in Appendix 2 -Advanced Programming pp. 233

Also- Follow the directions carefully and exactly on how to create a Merge print in an application.

only change the "Modifiable Parameters" as needed for your application

Special note on:
the vData Path The "program" will create the data source file. DONT TRY TO CREATE IT YOUR SELF.

DON'T CONFUSE OTHER PRINT DOCUMENTATION WITH THE MERGE PRINT PROGRAM.

•The vDataPath variable specifies the path to the data source file (customer.txt, in this case) that the program will create for your Word merge documents to use. If you don’t have a c:\sesame\docs\ folder, we recommend that you create it now rather than changing the parameter in the program.

•The vDocsPath variable is the path to the folder where your Word merge documents are stored. The default is c:\sesame\docs\.

•The vWordPath variable is the path to the word.bat batch file you created earlier: c:\sesame\word.bat.

Smiley SmileySpecial Thanks Smiley  to   SmileyTom Marcellous Smiley  for his support
And for those of you that have not subscribed to "Inside Sesame" I strongly encourage it. I subscribed and in two issues have applied many things to my Sesame applications. It has monthly issue (12-16) pages  of great topics. I think it serves a great medium to decrease the learning curve time and optimize your knowledge base.

Regards,

Dave Costanzo


« Last Edit: Feb 8th, 2004 at 3:26pm by dcostanzo »  
Back to top
 
IP Logged