Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default Test to see if a workbook is open

I can't find anything in Help on this. When I open workbook "A" I want to
know if workbook "B" is already open because I'll do something in "A" as it
opens if that is the case.

The other thing I'd really like to know is if you can print from a workbook
that is not open.

Can anyone help please?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Test to see if a workbook is open

Reply (from a previouspostin) courtesy of Ron De Bruin:

You can use the workbook open event to run the code
http://www.cpearson.com/excel/events.htm

Then you can open the workbook like this

If bIsBookOpen("test.xls") Then
Set destWB = Workbooks("test.xls")
Else
Set destWB = Workbooks.Open("c:\test.xls")
End If

Copy this function in a normal module

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

Re printing - I don't believe you can.


"Brettjg" wrote:

I can't find anything in Help on this. When I open workbook "A" I want to
know if workbook "B" is already open because I'll do something in "A" as it
opens if that is the case.

The other thing I'd really like to know is if you can print from a workbook
that is not open.

Can anyone help please?

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
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
Need VB code for workbook open to open a link Daniel Baker Excel Discussion (Misc queries) 2 August 18th 06 01:30 AM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
Excel workbook does not open in open window on desktop DeanH Excel Discussion (Misc queries) 2 March 8th 05 09:51 AM
Importing Data from unopened Workbook into an open Workbook GrayesGhost Excel Discussion (Misc queries) 0 March 5th 05 11:25 PM


All times are GMT +1. The time now is 04:59 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"