I THINK you might be better off if you open a second file as the
destination and write to it. Once you have finished, you can delete the
source file (if you wish) and rename the destination file with the name
of the source file.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Stephen Lynch wrote:
> I am looking to open a text file, input each line and rewite the line adding
> a file name plus 1. For example:
>
> Original text file
> John, Doe, Chicago
> Jane, Doe, Chicago
>
> What I want
> John, Doe, Chicago, 1
> Jane, Doe, Chicago, 2
>
>
> Also, I am refering to a file name that I have declared in another function
> as a string so I am not sure if I need to change that. But here's where I
> am, just learning.
>
>
> Function Add1toEndofFile(FileID As String)
>
> Dim strOneLine As String
> Dim strCounter As Integer
> FileID = FreeFile
> Open FileID For Input As #FileID
> Do Until EOF(FileID)
> Line Input #FileID, strOneLine
> Print strOneLine, FileID &" "& strCounter
> strCounter = strCounter + 1
> Loop
> Close #FileID
>
> But I am getting all kinds of errors. What I want to do is open the same
> file and just add the filename and counter line to the end of each line.
>
> Thanks for any assistance.
>
>
> End Function
>
>
>
|