check if file is in particular folder

  • Thread starter Thread starter nikolaosk
  • Start date Start date
N

nikolaosk

hi there,

i have a workbook and the user is asked to save the workbook under the
name "costs.xls"in a folder called "tests" in the current desktop.


how can i check using VBA that the user has saved the open workbook as
"costs.xls" and then check that he indeed saved it in the "tests"
folder on the desktop?


basically, how can i check that there is a folder "tests" on the
desktop with a file "costs.xls" in it ?


thanks
 
I f you haven't already done so, you might want to get familiar with
Microsofts Scripting Runtime Library, scrrun.dll. It contains, among other
things, an object called "FileSystemObject". This object has a method
called "FolderExists".

An alternative to the above is:

Public Function FolderExists(sDirectory) As Boolean
Dim sPathAttr As String

On Error GoTo Bail

FolderExists = False

sPathAttr = GetAttr(sDirectory) And 0

FolderExists = True

Bail:
End Function



Bill Barclift
 
Back
Top