Shared Workbook

J

Jako

I want to set up a workbook that can be shared by upto 3 users.

What i need to do is :

1) Check if Workbook exists

then

2) Check if the Workbook is in use

The path will be R:\Shared\Excel

the Workbook name is EPLCDATA.xls

I would like to display a message saying that

The Workbook Exists / Doesn't Exist

and then

a message if the Workbook is already open.


Any advice appreciated.


Thanks in advance
 
D

Dave Peterson

To check if the file exists:

dim myPath as string
dim myFileName as string
dim tstWkbk as workbook

myfilename = "EPLCDATA.xls"
mypath = "R:\Shared\Excel\"

if dir(mypath & myfilename) = "" then
msgbox "it ain't there
else
msgbox "yep, it's out there!"
end if

set tstwkbk = nothing
on error resume next
set tstwkbk = workbooks(myFilename)
on error goto 0

if tstwkbk is nothing then
msgbox "it ain't open"
elseif lcase(tstwkbk.path) <> lcase(mypath) then
msgbox "something with that name is open--but not the right folder!"
else
msgbox "yep, it's open"
end if
 
Top