Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error Handling - Check a file isn't already open before overwritin | Excel Discussion (Misc queries) | |||
Problem with handling on error when file is already open | Excel Programming | |||
workbooks.open and error handling | Excel Programming | |||
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed | Excel Programming | |||
Error Handling Open Function or query for missing Files | Excel Programming |