ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   In Macros - compilation error (https://www.excelbanter.com/excel-programming/377488-macros-compilation-error.html)

Vijay Kotian

In Macros - compilation error
 
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.



Ardus Petus

In Macros - compilation error
 

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,
--
AP

"Vijay Kotian" a écrit dans le
message de news: ...
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.





Ardus Petus

In Macros - compilation error
 
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,
--
AP

"Ardus Petus" a écrit dans le message de news:
...

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,
--
AP

"Vijay Kotian" a écrit dans le
message de news:
...
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.







Ardus Petus

In Macros - compilation error
 
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


"Ardus Petus" a écrit dans le message de news:
...
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,
--
AP

"Ardus Petus" a écrit dans le message de news:
...

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,
--
AP

"Vijay Kotian" a écrit dans le
message de news:
...
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.










All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com