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

I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.

I have:-
i) Worksbooks.Open("Filename.xls")

and
ii) Windows("Filename.xls).Activate

but I require somethiing to stop the 'overwrite' message popping up after
running i), if already open, and then running ii)

Hope this makes sense

Any help appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Identify open Workbooks

Hi SyZyGy

One way

You can test it with a function

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Book11.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SyZyGy" wrote in message ...
I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.

I have:-
i) Worksbooks.Open("Filename.xls")

and
ii) Windows("Filename.xls).Activate

but I require somethiing to stop the 'overwrite' message popping up after
running i), if already open, and then running ii)

Hope this makes sense

Any help appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Identify open Workbooks

Ron

Thanks for the response

I do not want the user to have to test if the workbook is already open. The
default microsoft 'overwrite' message prompt is effectively doing this.

My requirement is to hide this test from the user and just open the workbook
window

regards - SyZyGy

"Ron de Bruin" wrote:

Hi SyZyGy

One way

You can test it with a function

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Book11.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SyZyGy" wrote in message ...
I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.

I have:-
i) Worksbooks.Open("Filename.xls")

and
ii) Windows("Filename.xls).Activate

but I require somethiing to stop the 'overwrite' message popping up after
running i), if already open, and then running ii)

Hope this makes sense

Any help appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Identify open Workbooks

I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.


Sub File_Open_test()
If bIsBookOpen("Book11.xls") Then
'you open code
Else
'your activate code
End If
End Sub

The code is doing what you want if you add the open and activate code line


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SyZyGy" wrote in message ...
Ron

Thanks for the response

I do not want the user to have to test if the workbook is already open. The
default microsoft 'overwrite' message prompt is effectively doing this.

My requirement is to hide this test from the user and just open the workbook
window

regards - SyZyGy

"Ron de Bruin" wrote:

Hi SyZyGy

One way

You can test it with a function

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Book11.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SyZyGy" wrote in message ...
I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.

I have:-
i) Worksbooks.Open("Filename.xls")

and
ii) Windows("Filename.xls).Activate

but I require somethiing to stop the 'overwrite' message popping up after
running i), if already open, and then running ii)

Hope this makes sense

Any help appreciated.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Identify open Workbooks

Thanks Ron

It took a bit of time for my brain to get into gear!

Regards - SyZyGy

"Ron de Bruin" wrote:

I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.


Sub File_Open_test()
If bIsBookOpen("Book11.xls") Then
'you open code
Else
'your activate code
End If
End Sub

The code is doing what you want if you add the open and activate code line


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SyZyGy" wrote in message ...
Ron

Thanks for the response

I do not want the user to have to test if the workbook is already open. The
default microsoft 'overwrite' message prompt is effectively doing this.

My requirement is to hide this test from the user and just open the workbook
window

regards - SyZyGy

"Ron de Bruin" wrote:

Hi SyZyGy

One way

You can test it with a function

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Book11.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SyZyGy" wrote in message ...
I am looking for the VBA to identify if a workbook is already open and, if
not, to open it, otherwise to open the workbook window.

I have:-
i) Worksbooks.Open("Filename.xls")

and
ii) Windows("Filename.xls).Activate

but I require somethiing to stop the 'overwrite' message popping up after
running i), if already open, and then running ii)

Hope this makes sense

Any help appreciated.





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
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. san Excel Programming 1 January 3rd 06 03:22 AM
How to identify variable workbooks in an excel Addin Martin in Frisco Texas Excel Programming 10 September 15th 05 08:05 PM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Identify if another user has spreadsheet open - in VBA gp Excel Programming 3 December 9th 03 09:10 PM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 02:18 AM.

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"