Hi Kapila,
I don't think Access 97 is any different from later versions in this
regard. Here's a little procedure that removes the first n lines from a
textfile; it only works with 8-bit (ANSI/ASCII) files, not Unicode, and
needs a lot of error trapping to make it bombproof.
'API function declaration needed at start of module
Declare Function GetTempFileName _
Lib "kernel32" Alias "GetTempFileNameA" _
(ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long
Public Sub DumpFirstLinesOfTextFile(FileSpec As String, _
LinesToDump As Long)
'Removes initial lines of a text file.
'ANSI/ASCII files only.
Dim oFSO As Scripting.FileSystemObject
Dim strFolder As String
Dim strTempFile As String
Dim j As Long
Dim tsIn As Scripting.TextStream
Dim tsOut As Scripting.TextStream
Dim fiF As Scripting.File
'Work out path and names, create temp file with unique name
Set oFSO = CreateObject("Scripting.FileSystemObject")
strFolder = oFSO.GetParentFolderName(FileSpec)
strTempFile = Space(255)
GetTempFileName strFolder, "$$$", 0, strTempFile
'GetTempFileName returns null-terminated string; trim it
strTempFile = Left(strTempFile, InStr(strTempFile, Chr(0)) - 1)
'Open input file
Set tsIn = oFSO.OpenTextFile(FileSpec, ForReading)
'Overwrite temp file
Set tsOut = oFSO.CreateTextFile(strTempFile, True)
'Do the deed
For j = 1 To LinesToDump
tsIn.SkipLine
Next
Do While Not tsIn.AtEndOfStream
tsOut.WriteLine tsIn.ReadLine
Loop
tsIn.Close
tsOut.Close
'Delete source file
'(Alternatively, rename it for a backup copy)
oFSO.DeleteFile FileSpec
'Give the temp file the original name
Set fiF = oFSO.GetFile(strTempFile)
fiF.Name = oFSO.GetBaseName(FileSpec) _
& "." & oFSO.GetExtensionName(FileSpec)
Set fiF = Nothing
Set oFSO = Nothing
End Sub