![]() |
Error handling on Workbooks.Open
Workbooks.Open ("H:\Checklist 07-23-07.xls")
Workbooks("CheckList.xls").Activate What would be the best way to handle the error if the file does not exist? |
Error handling on Workbooks.Open
filename = Dir(("H:\Checklist 07-23-07.xls")
if filename = < then 'enter errror code else Workbooks.Open ("H:\Checklist 07-23-07.xls") end if "Tom" wrote: Workbooks.Open ("H:\Checklist 07-23-07.xls") Workbooks("CheckList.xls").Activate What would be the best way to handle the error if the file does not exist? |
Error handling on Workbooks.Open
The "best way" will depend on what you want to happen if the file
doesn't exist (e.g., do you want to exit the sub silently? Put up an error message? invoke a dialog to find the file?). One of the simplest: Dim wkbk As Workbook On Error Resume Next Set wkbk = Workbooks.Open("H:\Checklist 07-23-07.xls") On Error GoTo 0 If wkbk Is Nothing Then Exit Sub ... In article , Tom wrote: Workbooks.Open ("H:\Checklist 07-23-07.xls") Workbooks("CheckList.xls").Activate What would be the best way to handle the error if the file does not exist? |
All times are GMT +1. The time now is 02:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com