View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Luedke Jim Luedke is offline
external usenet poster
 
Posts: 43
Default What is the test for whether a file is open?

What's the test for whether a file is currently open (or closed)?

My app writes to a log file, but I don't want to burden the caller
with opening the file in the event he never has to write to it. So I
want:

Dim H As Long

Sub Log(Msg as String)
If Not IsOpen(H) then
Open LogFile For Output As #H
Print #H, FileHeader & DateTime
Print #H,
End If

Print #H, Msg
End Sub

Sub Main
Repeat
If Not Something Then
Log "Oops"
End If
Until SomethingElse
Close #H
End Sub

So what expression should "IsOpen(H)" be?

Thanks.

***