Text files are also sometimes known as sequential files
Private Function FileNameOnly(sFullPath As String) As String
Dim I As Integer
Dim length As Integer
Dim temp As String
Length = Len(sFullPath)
temp = ""
For I = length to 1 Step -1
If Mid(sFullPath,I,1) = Application.PathSeparator Then
FileNameOnly = temp
temp = Mid(sFullPath,I,1) & temp
FileNameOnly = sFullPath
The Dir function attempts to match its input argument against existing files.
This function can be used with valid wild cards under Windows for matches such as "*.xls".
If it finds a match, it returns the first match found and can be called again without an input argument to get subsequent matches.
Does a file exist
If Dir("C:\Temp.xls") <> "" Then
'then the file exists
Dim sFolderPath As String
If Dir(sFolderPath, vbDirectory) <> "" Then 'folder path exists
'folder path does not exist
There are three ways to access a file
This methods starts reading from the start and reads a line at a time
The Open statement is used to open your file.
You can specify the exact position in a file using the Seek() function.