ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test if a Workbook is Open (https://www.excelbanter.com/excel-programming/418814-test-if-workbook-open.html)

RyanH

Test if a Workbook is Open
 
Is there a way to test if a workbook is open anywhere in the network? I
currently have a macro that tests if a workbook is open, but it only works if
it is open on the users computer.

I have a Source Workbook that transfers data to an Archive Workbook. I want
to make sure that someone isn't using the Archive Workbook before I transfer
the data. Is this possible?

Thanks in Advance!
--
Cheers,
Ryan

Incidental

Test if a Workbook is Open
 
Hi Ryan

You can check out the MS sites listed in the post below by Tom Ogilvy
they should help you out.

http://groups.google.co.uk/group/mic...06e446e41e7314

Thanks

Steve

Bob Phillips[_3_]

Test if a Workbook is Open
 

Function IsFileOpen(FileName As String)
Dim iFilenum As Long
Dim iErr As Long

On Error Resume Next
iFilenum = FreeFile()
Open FileName For Input Lock Read As #iFilenum
Close iFilenum
iErr = Err
On Error GoTo 0

Select Case iErr
Case 0: IsFileOpen = False
Case 70: IsFileOpen = True
Case Else: Error iErr
End Select

End Function

Sub test()
If Not IsFileOpen("C:\MyTest\volker2.xls") Then
Workbooks.Open "C:\MyTest\volker2.xls"
End If
End Sub


--
__________________________________
HTH

Bob

"RyanH" wrote in message
...
Is there a way to test if a workbook is open anywhere in the network? I
currently have a macro that tests if a workbook is open, but it only works
if
it is open on the users computer.

I have a Source Workbook that transfers data to an Archive Workbook. I
want
to make sure that someone isn't using the Archive Workbook before I
transfer
the data. Is this possible?

Thanks in Advance!
--
Cheers,
Ryan




Dave Peterson

Test if a Workbook is Open
 
Microsoft shares a way to check to see if the file is open he
http://support.microsoft.com?kbid=138621
Microsoft's IsFileOpen function.

RyanH wrote:

Is there a way to test if a workbook is open anywhere in the network? I
currently have a macro that tests if a workbook is open, but it only works if
it is open on the users computer.

I have a Source Workbook that transfers data to an Archive Workbook. I want
to make sure that someone isn't using the Archive Workbook before I transfer
the data. Is this possible?

Thanks in Advance!
--
Cheers,
Ryan


--

Dave Peterson


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com