This self-contained routine can be pasted into a code module and called from anywhere, including the immediate window. It will expect you to pass the name of a file (including the path if it isn't in the current directory) and will copy the contents of the file to the immediate window. Note it will also avoid, as far as possible, interfering with any other processing which may be going on at the time.
Expand|Select|Wrap|Line Numbers
- Public Sub DumpFile_V01(ByVal FileName As String)
- Dim FileNo As Long
- Dim LineNo As Long
- Dim LineText As String
- FileNo = FreeFile ' Get next available file number.
- Open FileName For Input Access Read Shared As #FileNo
- Do Until EOF(FileNo) ' Repeat until end of file...
- Line Input #FileNo, LineText ' Read a line from the file.
- LineNo = LineNo + 1
- Debug.Print Format(LineNo, "00000"); ": "; LineText
- DoEvents ' Allow Windows to handle other tasks.
- Loop
- Close #FileNo
- End Sub