Possible Duplicate:
Any way to automatically move contents of immediate window into a text file?
Is it possible to log the Debug.Print output to a text file instead of the Immediate window in Excel VBA?
Possible Duplicate:
Any way to automatically move contents of immediate window into a text file?
Is it possible to log the Debug.Print output to a text file instead of the Immediate window in Excel VBA?
You should see the fabulous answer by Jean-François Corbett here:
As he states, it makes little sense to write to the immediate window, then copy and paste it when you could just write to an output txt file at the same time (or just the txt file if that is what you want).
Example from his answer:
Dim s As String
Dim n As Integer
n = FreeFile()
Open "C:\test.txt" For Output As #n
s = "Hello, world!"
Debug.Print s ' write to immediate
Print #n, s ' write to file
Close #n