Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default test for workbook open

Need a method to see if a file (WORKBOOK) is in use so the
file open command via VBA does not open it read only. It
should display a warning and then a time delay.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default test for workbook open

Rich,

Here is one way. It opens the book and then closes it if it is read only

Dim sFile As String

sFile = "C:\myTest\Volker1.xls"
On Error GoTo file_error
Workbooks.Open Filename:=sFile
If ActiveWorkbook.ReadOnly = True Then
CreateObject("WScript.Shell").Popup sFile & " is in use/read-only",
5, "Title", vbYesNo
ActiveWorkbook.Close savechanges:=False
Exit Sub
End If
Exit Sub
file_error:
MsgBox "Error " & Err.Number & " on file " & sFile


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rich C" wrote in message
...
Need a method to see if a file (WORKBOOK) is in use so the
file open command via VBA does not open it read only. It
should display a warning and then a time delay.
Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
VBA Assistance needed to test for open file in a different direct Brent E Excel Discussion (Misc queries) 2 April 30th 07 11:39 PM
Test to see if a workbook is open Brettjg Excel Discussion (Misc queries) 1 March 5th 07 09:26 AM
Test to see if a spreadsheet window is open lopsided[_6_] Excel Programming 2 December 17th 03 10:42 AM


All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"