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

I'm sure I've seen this in the group before but I can't find it.

How would I check to see if a specific workbook is already open?

Jesse


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Checking if workbook is open

Hi Jesse,

Function IsWBopen(wb As String) As Boolean
On Error Resume Next
IsWBopen = Len(Workbooks(wb).Name) 0
End Function

Sub test()
MsgBox IsWBopen("funcres.xla")'your workbook name
End Sub


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
(Excel Add-ins)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Checking if workbook is open

Jesse,

A couple of alternatives

Function IsFileOpen(fName) As Boolean
On Error Resume Next
IsFileOpen = Len(Workbooks(fName).Name)
On Error Goto 0
End Function

and is invoked with a simple

IsFileOpen("Misc.xls")

or

Function GetFile(fName) As Workbook
On Error Resume Next
Set GetFile = Workbooks(fName)
On Error GoTo 0
End Function

and is used in this type of way

sFile = "Premiership 2003.xls"
If GetFile(sFile) Is Nothing Then
MsgBox sFile & " file needs to be open"
Else
MsgBox sFile & " file is already open"
End If

--

HTH

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

"Jesse" wrote in message
news:OliAb.21930$bC.17512@clgrps13...
I'm sure I've seen this in the group before but I can't find it.

How would I check to see if a specific workbook is already open?

Jesse




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checking if workbook is open

For Each C In Workbooks()
If C.Name = "Book1" Then MsgBox "Workbook " & C.Name & "
is open ...", vbInformation
Next C

-----Original Message-----
I'm sure I've seen this in the group before but I can't

find it.

How would I check to see if a specific workbook is

already open?

Jesse


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Checking if workbook is open

Bob, this worked better than I expected and saved me tons of time. Thanks
for your help.

Jesse



"Bob Phillips" wrote in message
...
Jesse,

A couple of alternatives

Function IsFileOpen(fName) As Boolean
On Error Resume Next
IsFileOpen = Len(Workbooks(fName).Name)
On Error Goto 0
End Function

and is invoked with a simple

IsFileOpen("Misc.xls")

or

Function GetFile(fName) As Workbook
On Error Resume Next
Set GetFile = Workbooks(fName)
On Error GoTo 0
End Function

and is used in this type of way

sFile = "Premiership 2003.xls"
If GetFile(sFile) Is Nothing Then
MsgBox sFile & " file needs to be open"
Else
MsgBox sFile & " file is already open"
End If

--

HTH

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

"Jesse" wrote in message
news:OliAb.21930$bC.17512@clgrps13...
I'm sure I've seen this in the group before but I can't find it.

How would I check to see if a specific workbook is already open?

Jesse








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Checking if workbook is open

Bob, this worked better than I expected and saved me tons of time. Thanks
for your help.

Jesse



"Bob Phillips" wrote in message
...
Jesse,

A couple of alternatives

Function IsFileOpen(fName) As Boolean
On Error Resume Next
IsFileOpen = Len(Workbooks(fName).Name)
On Error Goto 0
End Function

and is invoked with a simple

IsFileOpen("Misc.xls")

or

Function GetFile(fName) As Workbook
On Error Resume Next
Set GetFile = Workbooks(fName)
On Error GoTo 0
End Function

and is used in this type of way

sFile = "Premiership 2003.xls"
If GetFile(sFile) Is Nothing Then
MsgBox sFile & " file needs to be open"
Else
MsgBox sFile & " file is already open"
End If

--

HTH

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

"Jesse" wrote in message
news:OliAb.21930$bC.17512@clgrps13...
I'm sure I've seen this in the group before but I can't find it.

How would I check to see if a specific workbook is already open?

Jesse






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Checking if workbook is open

Jesse,

Just read your response, so thanks for that, and glad to help.

--

HTH

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

"Jesse" wrote in message
...
Bob, this worked better than I expected and saved me tons of time. Thanks
for your help.

Jesse



"Bob Phillips" wrote in message
...
Jesse,

A couple of alternatives

Function IsFileOpen(fName) As Boolean
On Error Resume Next
IsFileOpen = Len(Workbooks(fName).Name)
On Error Goto 0
End Function

and is invoked with a simple

IsFileOpen("Misc.xls")

or

Function GetFile(fName) As Workbook
On Error Resume Next
Set GetFile = Workbooks(fName)
On Error GoTo 0
End Function

and is used in this type of way

sFile = "Premiership 2003.xls"
If GetFile(sFile) Is Nothing Then
MsgBox sFile & " file needs to be open"
Else
MsgBox sFile & " file is already open"
End If

--

HTH

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

"Jesse" wrote in message
news:OliAb.21930$bC.17512@clgrps13...
I'm sure I've seen this in the group before but I can't find it.

How would I check to see if a specific workbook is already open?

Jesse








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
RETRIEVE DATA FROM ANOTHER WORKBOOK BY CHECKING ON WORKBOOK DATE Joe Excel Worksheet Functions 13 May 27th 08 01:52 AM
Checking if workbook open (where path is unknown) [email protected] Excel Programming 0 September 4th 03 11:13 PM
Checking for Open Workbook sbharbour Excel Programming 6 August 28th 03 11:42 PM
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


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