ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IN MACROS HOW TO IGNORE ANY FILE. (https://www.excelbanter.com/excel-programming/377324-re-macros-how-ignore-any-file.html)

Chip Pearson

IN MACROS HOW TO IGNORE ANY FILE.
 
Here's one that is shorter and doesn't use Goto.

Function IsWorkbookOpen(WBName As String) As Boolean
On Error Resume Next
IsWorkbookOpen = CBool(Len(Workbooks(WBName).Name))
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)


"WhytheQ" wrote in message
oups.com...
similar to Bob's :

Private Function IsFileOpen(strFile As String) As Boolean

Dim aName As String

On Error GoTo NotOpen:
aName = Workbooks(strFile).Name
IsFileOpen = True
GoTo FunctionEnd:
NotOpen:
IsFileOpen = False
FunctionEnd:

End Function

Rgds
J

On Nov 14, 11:48 am, "Bob Phillips" wrote:
Just try opening but handling any errors

On Error Resume Next
Set oWB = Workbooks.Open("C:\MyTest\myFile.xls")
On Error Goto 0
If oWB Is Nothing Then
MsgBox "File doen't exist here"
End If

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Vijay Kotian" wrote in
...



In Excel Macros, if particiular file specified is not available in the
harddisk or any other source while opening i always get a error message
(debug mode). How is it possible to ignore without debugging the
program
every time?


Pl. Help if any other alternatives are available..


Thanx- Hide quoted text -- Show quoted text -






All times are GMT +1. The time now is 11:57 PM.

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