Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Opening questions

Dim bk as workbook
On Error Resume Next
set bk = WorkBooks("ws2.xls")
On Error goto 0
if not bk is nothing then
msgbox "ws2.xls is open"
else
set bk = workbooks.open( Filename:="c:\ws2.xls")
End If

Regards,
Tom Ogilvy

"Joe" wrote in message
...
Hi Everybody:

I built this VBA script for Excel and I'm running into a
bit of a problem. I have 2 seperate workbooks(We'll call
them ws1 and ws2). What I want to do is determine if ws2
is open. Is there a way to determine if it's open or not?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Opening questions

http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

Should give you what you want.

--
Regards,
Tom Ogilvy


flashpoint wrote in message
...
On Fri, 15 Aug 2003 13:08:52 -0400, "Tom Ogilvy"
wrote:

Dim bk as workbook
On Error Resume Next
set bk = WorkBooks("ws2.xls")
On Error goto 0
if not bk is nothing then
msgbox "ws2.xls is open"
else
set bk = workbooks.open( Filename:="c:\ws2.xls")
End If

Regards,
Tom Ogilvy



Your code works as advertized but let throw a wrench
into the works and say that there are multiple instances
of excel open on the same PC and that the file you are
checking for could be open on any of them?



... thoughts?

Thanks,
Cal



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Opening questions

Cal,

If those instances didn't open the file as readonly
then try something like:

set wb=Workbooks.Open(FileName:="c:\test.xls", _
Readonly:=False,IgnoreReadOnlyRecommended:=True)

if not wb is nothing then
if wb.ReadOnly then BEEP
end if


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


flashpoint wrote:

On Fri, 15 Aug 2003 13:08:52 -0400, "Tom Ogilvy"
wrote:

Dim bk as workbook
On Error Resume Next
set bk = WorkBooks("ws2.xls")
On Error goto 0
if not bk is nothing then
msgbox "ws2.xls is open"
else
set bk = workbooks.open( Filename:="c:\ws2.xls")
End If

Regards,
Tom Ogilvy



Your code works as advertized but let throw a wrench
into the works and say that there are multiple instances
of excel open on the same PC and that the file you are
checking for could be open on any of them?



... thoughts?

Thanks,
Cal


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 do I stop blank workbook from opening when opening an existing kjg Excel Discussion (Misc queries) 3 February 12th 10 09:36 PM
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
Opening specific worksheet from hyperlink more questions lots of questions Excel Discussion (Misc queries) 0 May 30th 07 09:53 PM
REF errors when opening excel in xp. works fine when opening wor. br Excel Discussion (Misc queries) 6 September 13th 05 11:41 AM


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