Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


vb/excel question

Posted on 2003-03-05
Medium Priority
Last Modified: 2010-04-07
i would like to know how to run a boolean operation on whether a file exists in a certain directory.
i know about the method FileExists


i just don't understand what a FileSystemObject is

thanks in advance for your help
Question by:jkenin
  • 2
LVL 18

Accepted Solution

bobbit31 earned 400 total points
ID: 8076449
no need for filesystemobject:

Function FileExists(path as String) as Boolean
   if Dir(path) <> "" then
       FileExists = true
       FileExists = false
   end if
end Function

Author Comment

ID: 8076504
actually i was wondering if there was a way to determine if a CERTAIN file was in a certain directory. sorry for the miscommunication.

thanks for the prompt reply!
LVL 18

Expert Comment

ID: 8076890
the above code will do it:

Dim strDir as String
Dim strFile as String

strDir = "C:\my documents\"
strFile = "test.txt"

msgbox FileExists(strDir & strFile)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question