Do not open the file! there is no need to open a file for textmerge to occur. Just set textmerge to (lcfilename) and let 'er rip. When you are done all you need to do is set textmerge to. Just like my example. The file is closed and ready to process in any other way.
Glenn
>I got that part working, what I need now is to close the silly file, and only close the file that was written so accpac can import the data written. Of course, it would be easier to get the client to upgrade thier accpac so I could ODBC instead, but....
>>Hi Lorne,
>>
>>I use textmerge quite a bit, and here is what I would do:
>>
>>lfullname = lpath + lfile
>>SET TEXTMERGE ON
>>SET TEXTMERGE TO (lFullName) noshow
>>\3
>>\2
>>\1
>>set textmerge to
>>modi file (lFullName)
>>
>>
>>
>>Glenn
>>
>>>I need to write an assortment of documents via textmerge. No problem with the format, it's opening files dynamicly that is messing up
>>> my code:
>>>lfullname = lpath + lfile
>>>lhfile = FOPEN(lfullname, 11)
>>>SET TEXTMERGE ON
>>>SET TEXTMERGE TO lhfile
>>>
>>>writes to a file called lhfile (lhfile.txt, not what it ought to be), not the file and path contained in lpath and lfile, and to close the file after exporting the data, I want to use the handle (lhfile). I have also tried it with TO lfullname to no avail, it still opens as lfullname.txt, not expinv.csv as in the var lfile.
>>>I can't hard code the file and path in, so I need to do it this way or similar.
>>>
>>>Thanks