I had overlooked that part - but can't you simply use the filename instead of a file handle? The file handles for fopen() are meant to be used to produce out put with fputs(), or fwrite(), not with TEXTMERGE.
You could still use fopen() or fcreate() to see whether you can access the file - and follow it by fclose().
>No joy, that expects a string, not a file handle number.
>Oh doing SET TEXTMERGE TO &lfullname works, but won't cleanly close the file
>
>>Although I never used TEXTMERGE seriously, I suspect the correct syntax, to work with a variable, would be:
>>
>>
>>...
>>SET TEXTMERGE TO (lhfile)
>>
>>
>>HTH,
>>
>>Hilmar.
>>
>>
>>>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
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)