TransferText Woes

  • Thread starter Thread starter quixote
  • Start date Start date
Q

quixote

I am trying to do the following but am not sure how to do
it.
Open Notepad
Write a header line
Write tilde delimited data from a table
Save the file and export it.



Any ideas...I'm getting a little confused with
TransferText, Call Shell and Open

Thanks
 
It looks like you are trying to write a text file. You could just write
it directly and not bother with the TransferText, Call Shell stuff.

In general, what I did was:

'Create a recordset using DAO or use RecordsetClone

'Hard code the path and filename (see below) or create a variable to
hold the path\filename - I once used the 'SaveAs' dialog box to be able
to pick the path\filename.

(Air code - this is an example)
' Open file for output.
OPEN "drive:\path\filename.txt" For Output As #1
'print today's date, move down two lines, print the header
Print #1, Date; vbCrLf; vbCrLf; HeaderText
'loop thru the recordset
Do While Not rs.EOF()
'create the tilde delimited line
for i = 1 to NumFields
textline = textline & field(i) & "~"
next
'get rid of last tilde
textline = left(textline,len(textline)-1)
'print the line and move down to next line
Print #1, textline; vbCrLf
Loop
'print a blank line
Print #1,
'print a footer etc. here, if you want
Print #1, "SomeText Here"
' Close file
Close #1


HTH

Steve
 
Back
Top