File Open

M

Mili

Hi,
How to check if the a perticular file is open or not ?
How to display true if the file is open.

Thanks

Regards

Mili.
 
H

Harald Staff

Hi Mili

Function IsOpen(WbName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(WbName).Name)
End Function

Sub test()
MsgBox IsOpen("Book1")
MsgBox IsOpen("MyPornArchive")
End Sub
 
M

Mili

Hi,

I am trying to test any file not only workbook.
any text file, or word file.

Thanks

Regards

Mili.
 
H

Harald Staff

That is somewhere between far worse and impossible. Especially for textfiles
and alike, they are not "open" as we know the word. Most apps, like notepad,
just read them and dump its content into a text field. Try opening a
textfile in Notepad, and then move it to some other folder with Windows
Explorer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top