I use a text file in my program to create a logfile as the program runs to help me debug it. However, sometimes it is left open and then when it tries to reopen it crashes. Here is the code that I use to open it:
[VBA]Dim logFile As String
logFile = "H:\@Temp\Daniel B\Log Files\" & Environ("UserName") & "_LogFile.txt"
FileNumber = FreeFile ' Get unused fileno
'Create file name.
Open logFile For Append As #FileNumber[/VBA]
How can I test to see if it is open first? I know how to do it with a word file and an excel file but I tried to figure that out but it is completely different.