How to skip opening an already open file

H

HH

Hi'

I have a script that opens a serie of Project files then makes a
change and then closes the file.

The problem is that sometimes a file is already open (by some user)
and the script stops (And I get the question if I want to open as read-
only).

How do I make it skip the already open file and continues to the next
file?

Thanks!
HH
 
G

Gary''s Student

This works for Excel. Perhaps you can adapt it:

Sub demo()
Dim IsItOpen As Boolean
IsItOpen = False
needopen = "Book3"
needopen2 = "Book3.xls"
For Each w In Workbooks
If w.Name = needopen Or w.Name = needopen2 Then
IsItOpen = True
End If
Next
If Not IsItOpen Then
Workbooks.Open Filename:= _
"C:\Documents and Settings\Owner\Desktop\Book3.xls"
End If
End Sub
 
H

HH

This works for Excel. Perhaps you can adapt it:

Sub demo()
Dim IsItOpen As Boolean
IsItOpen = False
needopen = "Book3"
needopen2 = "Book3.xls"
For Each w In Workbooks
If w.Name = needopen Or w.Name = needopen2 Then
IsItOpen = True
End If
Next
If Not IsItOpen Then
Workbooks.Open Filename:= _
"C:\Documents and Settings\Owner\Desktop\Book3.xls"
End If
End Sub

--
Gary's Student
gsnu200705









- Vis tekst i anførselstegn -

Hi'

Nice idea, but your script only test if the file already is opened on
your machine. My problem is that other users can open the file cross
the network.
 
G

Gary''s Student

In that case I would let the server to the work. Consider a SharePoint or
similar technology. You would have the ability to lock a file for editting,
to permit read-only access, to view which users are accessing the file, etc..

There is probably a good reason that most of the universe has decided not to
instrument this functionality on the client side.
 
H

HH

In that case I would let the server to the work. Consider a SharePoint or
similar technology. You would have the ability to lock a file for editting,
to permit read-only access, to view which users are accessing the file, etc..

There is probably a good reason that most of the universe has decided notto
instrument this functionality on the client side.

--
Gary's Student
gsnu200705





- Vis tekst i anførselstegn -

Hi

Well only problem is that I have no SharePoint or similar technology.
I work on at low-tech solution until the company total solution is in
place. I work on an old-fasion file-server.

I just hopeded there would be at way to ask for the status for a file.
 
G

Gary''s Student

I'll ask around
--
Gary''s Student
gsnu200705


HH said:
Hi

Well only problem is that I have no SharePoint or similar technology.
I work on at low-tech solution until the company total solution is in
place. I work on an old-fasion file-server.

I just hopeded there would be at way to ask for the status for a file.
 

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