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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top