Test of existance of worksheet

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

Guest

I am importing worksheets into a ms access database model. I have had
occasions where users have deleted the worksheets, moved them, etc. I would
like to to test for their existance before I run my import routines. How
would i write that?
 
Use the Dir command in VBA.

Example:
strWorksheet = "C:\My Documents\MyWorksheet.xls"
If Dir(strWorkSheet) <>"" Then
'do what you need to here
End If

The Dir command will return a zero length string if the file isn't found or
will return the file name if the file is found.
 
Back
Top