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

I've put a button on a spreadsheet that opens another workbook, works
fine if the other workbook isn't already open.

What I need to do, is to modify this so that it checks to see if this
workbook is already open, and if it is pop-up a message box saying the
workbook is already open, otherwise it can just go ahead and open the
closed workbook...

TIA for any suggestions.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking for Open Workbook

The box still comes up saying the workbook is already open...
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Checking for Open Workbook

With this code??? -- Not for me.

Sub Tester11()
Dim wkbk As Workbook
On Error Resume Next
Set wkbk = Workbooks("BigData1.xls")
On Error GoTo 0
If wkbk Is Nothing Then
Set wkbk = Workbooks.Open("C:\Data\BigData1.xls")
End If
wkbk.Activate

End Sub

I can't believe that - it doesn't try to open the workbook if it is already
open.

Sub Tester11()
Dim wkbk As Workbook
Dim sName as String, sPath
sName = "BigData1.xls"
sPath = "C:\Data\"
On Error Resume Next
Set wkbk = Workbooks(sName)
On Error GoTo 0
If wkbk Is Nothing Then
Set wkbk = Workbooks.Open(sPath & sName)
End If
wkbk.Activate

End Sub

The above minimizes the posibility of typing in different names.

--
Regards,
Tom Ogilvy




"sbharbour" wrote in message
...
The box still comes up saying the workbook is already open...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking for Open Workbook

It does try to open the book that is already open, but what I want to do
is suppress the message box telling that it's already open reopening
will cause changes to be discarded, do you want to reopen Yes No

???
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Checking for Open Workbook

The original code did that - the new code I posted does not.

If you suppress that message, then I am not sure whether it re-opens it or
not. Generally suppressing the message takes the default action which
appears to be to reopen the workbook - which could result in loss of data.

To suppress messages

Application.DisplayAlerts = False

' code that would cause the alert

Application.DisplayAlerts = True

But like I said, the second set of code does not try to open the workbook if
it is already open.

--
Regards,
Tom Ogilvy


"sbharbour" wrote in message
...
It does try to open the book that is already open, but what I want to do
is suppress the message box telling that it's already open reopening
will cause changes to be discarded, do you want to reopen Yes No

???





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking for Open Workbook

Thanks I've been playing with Application.DisplayAlerts = Flase

But I can't seem to get the code that caused the alert part...

I still get the alert

I've tried Workbooks.Open

and have been hunting for a list of Excel Alert boxes, thinking that
would solve the problem, but I'm still straching my head on this one...
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
Checking for Duplicates within a Workbook RAYCV Excel Worksheet Functions 7 September 23rd 08 12:10 PM
RETRIEVE DATA FROM ANOTHER WORKBOOK BY CHECKING ON WORKBOOK DATE Joe Excel Worksheet Functions 13 May 27th 08 01:52 AM
checking if workbook is open before accessing David Goodall Excel Programming 1 August 22nd 03 08:43 PM
VBA Excel Checking whether an XL file is already open elsewhere Kamal Hussain Excel Programming 2 August 19th 03 02:03 PM
Using wildcard for checking whether files are open [email protected] Excel Programming 1 July 30th 03 06:47 PM


All times are GMT +1. The time now is 09:32 PM.

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

About Us

"It's about Microsoft Excel"