Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2006, 03:15 PM
Authorized User
 
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Testing for File Busy

I have a series of Excel Workbooks that reside on a server. Through VBE I am working with different workbooks. Now I run the possibility that different users may try to access the same workbook at the same time. Is there a way to check for a workbook being busy before opening it so that I can prevent this problem? I'm already using Scripting.FileSystemObjects to check for the existence of folders and files, but I don't see any way to do what I want. Thanks for any help anyone can give.

Terry
 
Old January 3rd, 2007, 02:53 PM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is probably a more elegant solution but you could try this...

Workbooks.Open "Name.xls", Notify:=False

This will prevent the file from opening if someone has it open already.


 
Old January 4th, 2007, 01:01 PM
Authorized User
 
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Elegant I don't need. I believe this coupled with an "on error" process should work just great.

Thanks!
 
Old January 4th, 2007, 03:41 PM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or you could just use an

IF statement to test to see if the file opened succesfully THEN
    carry out any actions on the file
ELSE
    do whatever alternative action if the file did not open
    (i.e. someone else was using it...)
End If
 
Old January 5th, 2007, 08:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

As it turns out you've effectively come up with the only solution to this problem.

There's a Microsoft KB article on this http://support.microsoft.com/kb/q138621/ which also provides a neat wrapper function to test for already open files. However, as previously stated its semantically the same as the already proposed solution.

Maccas






Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing Soap envelop (as Text File) in RPC Method neerajdeswal ASP.NET 1.x and 2.0 Application Design 0 May 1st, 2007 06:55 AM
Server too Busy innochig ASP.NET 1.0 and 1.1 Professional 0 February 1st, 2007 08:12 AM
[Microsoft][ODBC SQL Driver]Connection is busy [email protected] Pro JSP 0 May 8th, 2006 07:51 AM
Dreamweaver Site Busy Error Message MarkL Dreamweaver (all versions) 7 February 1st, 2005 05:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.