Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
The company I work for has a network and when a shared file is open, I ususally get a pop-up box that asks if I want to open the file as read only, wait for notificatin that the file is OK to open or cancel. I have written some code (see attached) and I don't get this box pop-up box letting me know that the file is already open and this creates file integrity problems if the file is already open by another user. I think I want the pop-up box, and I am open to other suggestions. Any ideas how to write the code? IsOpen = False For Each wb In Workbooks 'check thru all open workbooks If wb.Name = "Master Log.xls" Then 'change to your file's name IsOpen = True 'your file is already End If Next wb If IsOpen = False Then Workbooks.Open Filename:="\\Tuc-nas\Master Log\Master Log.xls" 'This opens the other workbook if it was closed End If Thanks, Cameron |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That only checks if the file is open in the same instance of excel.
Perhaps the more general http://support.microsoft.com?kbid=138621 XL: Macro Code to Check Whether a File Is Already Open http://support.microsoft.com?kbid=291295 XL2002: Macro Code to Check Whether a File Is Already Open http://support.microsoft.com?kbid=213383 XL2000: Macro Code to Check Whether a File Is Already Open http://support.microsoft.com?kbid=184982 WD97: VBA Function to Check If File or Document Is Open is what you want. -- Regards, Tom Ogilvy "Cameron" wrote in message ... Hello, The company I work for has a network and when a shared file is open, I ususally get a pop-up box that asks if I want to open the file as read only, wait for notificatin that the file is OK to open or cancel. I have written some code (see attached) and I don't get this box pop-up box letting me know that the file is already open and this creates file integrity problems if the file is already open by another user. I think I want the pop-up box, and I am open to other suggestions. Any ideas how to write the code? IsOpen = False For Each wb In Workbooks 'check thru all open workbooks If wb.Name = "Master Log.xls" Then 'change to your file's name IsOpen = True 'your file is already End If Next wb If IsOpen = False Then Workbooks.Open Filename:="\\Tuc-nas\Master Log\Master Log.xls" 'This opens the other workbook if it was closed End If Thanks, Cameron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
XL2007 - Can't open a file that is in use on the network | Excel Discussion (Misc queries) | |||
Excel Silently Crashing when Network file is open | Excel Discussion (Misc queries) | |||
Windows API to get network username of person with file open | Excel Programming | |||
excel does not open file in network | Excel Worksheet Functions | |||
How do I open a file from a Network drive using Excel VBA? | Excel Programming |