Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Resume Next doesn't work in IsOpen function

I want to test if a workbook is open. I've found these suggestions, but none of them work for me. Any ideas why
Thank
Ro

'I've tried
Function IsOpen(BookName As String) As Boolea
On Error Resume Nex
Set wb = Workbooks(BookName
IsOpen = Not wb Is Nothin
End Functio

'and
Function IsOpen(BookName As String) As Boolea
On Error Resume Nex
IsOpen = Not (Application.Workbooks(BookName) Is Nothing
End Functio

'and
Function IsOpen(BookName As String) As Boolea
On Error Resume Nex
IsOpen = Len(Workbooks(BookName).Name
End Functio

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Resume Next doesn't work in IsOpen function

All three of the IsOpen functions work for me. Note that if the
workbook you are testing for has been saved, you must include the
".xls" file extension in the BookName. For example,

If IsOpen("Book1.xls") = True Then ' note the ".xls"

will always work if the workbook has been saved, but

If IsOpen("Book1") = True Then ' note the missing ".xls"

may not work if the workbook has been saved. It depends on the
Windows Explorer "Hide extensions for known file types" setting.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Rob" wrote in message
...
I want to test if a workbook is open. I've found these

suggestions, but none of them work for me. Any ideas why?
Thanks
Rob

'I've tried:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing
End Function

'and:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Not (Application.Workbooks(BookName) Is Nothing)
End Function

'and:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(BookName).Name)
End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Resume Next doesn't work in IsOpen function

What does "none of them work for me" mean?

--

Vasant

"Rob" wrote in message
...
I want to test if a workbook is open. I've found these suggestions, but

none of them work for me. Any ideas why?
Thanks
Rob

'I've tried:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing
End Function

'and:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Not (Application.Workbooks(BookName) Is Nothing)
End Function

'and:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(BookName).Name)
End Function



  #4   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Resume Next doesn't work in IsOpen function

When I step through (or run the code of the function), I still get the error message on the second line below, where I expect it to just continue onto the next line
On Error Resume Nex
Set wb = Workbooks(BookName
IsOpen = Not wb Is Nothin



----- Vasant Nanavati wrote: ----

What does "none of them work for me" mean

--

Vasan

"Rob" wrote in messag
..
I want to test if a workbook is open. I've found these suggestions, bu

none of them work for me. Any ideas why
Thank
Ro
'I've tried

Function IsOpen(BookName As String) As Boolea
On Error Resume Nex
Set wb = Workbooks(BookName
IsOpen = Not wb Is Nothin
End Functio
'and

Function IsOpen(BookName As String) As Boolea
On Error Resume Nex
IsOpen = Not (Application.Workbooks(BookName) Is Nothing
End Functio
'and

Function IsOpen(BookName As String) As Boolea
On Error Resume Nex
IsOpen = Len(Workbooks(BookName).Name
End Functio

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Resume Next doesn't work in IsOpen function

OK, let's take it step by step. *What* error message do you get?

For the example you gave, have you declared the variable wb?

--

Vasant

"Rob" wrote in message
...
When I step through (or run the code of the function), I still get the

error message on the second line below, where I expect it to just continue
onto the next line.
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing



----- Vasant Nanavati wrote: -----

What does "none of them work for me" mean?

--

Vasant

"Rob" wrote in message
...
I want to test if a workbook is open. I've found these

suggestions, but
none of them work for me. Any ideas why?
Thanks
Rob
'I've tried:

Function IsOpen(BookName As String) As Boolean
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing
End Function
'and:

Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Not (Application.Workbooks(BookName) Is Nothing)
End Function
'and:

Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(BookName).Name)
End Function





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Resume Next doesn't work in IsOpen function

If "On Error Resume Next" is being ignored:

In the VBE: ToolsOptionsGeneral. Make sure you have "Break on Unhandled
errors" set, not "Break on all errors".

--
George Nicholson

Remove 'Junk' from return address.


"Rob" wrote in message
...
When I step through (or run the code of the function), I still get the

error message on the second line below, where I expect it to just continue
onto the next line.
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing



----- Vasant Nanavati wrote: -----

What does "none of them work for me" mean?

--

Vasant

"Rob" wrote in message
...
I want to test if a workbook is open. I've found these

suggestions, but
none of them work for me. Any ideas why?
Thanks
Rob
'I've tried:

Function IsOpen(BookName As String) As Boolean
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing
End Function
'and:

Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Not (Application.Workbooks(BookName) Is Nothing)
End Function
'and:

Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(BookName).Name)
End Function



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Resume Next doesn't work in IsOpen function

Good point, George; I didn't even think about that.

--

Vasant

"George Nicholson" wrote in message
...
If "On Error Resume Next" is being ignored:

In the VBE: ToolsOptionsGeneral. Make sure you have "Break on Unhandled
errors" set, not "Break on all errors".

--
George Nicholson

Remove 'Junk' from return address.


"Rob" wrote in message
...
When I step through (or run the code of the function), I still get the

error message on the second line below, where I expect it to just continue
onto the next line.
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing



----- Vasant Nanavati wrote: -----

What does "none of them work for me" mean?

--

Vasant

"Rob" wrote in message
...
I want to test if a workbook is open. I've found these

suggestions, but
none of them work for me. Any ideas why?
Thanks
Rob
'I've tried:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
Set wb = Workbooks(BookName)
IsOpen = Not wb Is Nothing
End Function
'and:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Not (Application.Workbooks(BookName) Is Nothing)
End Function
'and:
Function IsOpen(BookName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(BookName).Name)
End Function





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
need a function that will work using multiple work books and sheet capt c Excel Worksheet Functions 1 March 30th 09 10:20 PM
How do I setup plain work sheet for preparing resume or timesheet Shahid Setting up and Configuration of Excel 1 July 9th 07 01:02 PM
resume.xlw OZDOC Excel Discussion (Misc queries) 6 July 31st 06 01:24 PM
can I create a new resume? in need of help. Excel Discussion (Misc queries) 1 August 10th 05 11:18 PM
On Error Resume Next Jim Sharrock Excel Programming 2 May 13th 04 03:12 PM


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

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"