In Macros - compilation error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

To check whether the file is already open or not i got a command "Res =
IsWorkbookOpen("BOOK3.xls")" when i am running this command i get a
compilation error as "sub or function not defined". Can anybody help me.
 
sub TestMe()
Dim oWb as WorkBook
on error resume next
set owb = Workbooks("Book3.xls")
on error goto 0
if oWB is nothing then
msgbox "not opened"
else
msgbox ("opened")
endif
end sub


Cheers,
 
As a function:

Function isOpened(sWB As String)
Dim oWb As Workbook
On Error Resume Next
Set oWb = Workbooks("Book3.xls")
On Error GoTo 0
isOpened = Not oWb Is Nothing
End Function

Cheers,
 
Ooops:

Function isOpened(sWB As String)
Dim oWb As Workbook
On Error Resume Next
Set oWb = Workbooks(sWB)
On Error GoTo 0
isOpened = Not oWb Is Nothing
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top