saving/creating a directory

  • Thread starter Thread starter mudraker
  • Start date Start date
Note: from Tom Ogilvy

sPath = "C:\Data"
if Dir(sPath,vbDirectory) <> "" then
if getAttr(sPath) = vbDirectory then
msgbox sPath & " exists"
end if
end if

You need to do the getAttr because Dir checks for both a file and a
directory when you do Dir(sPath,vbDirectory), so it could be fooled by a
file named C:\data with no extension.
 
Hi,

I have a macro which automatically saves the workbook to the path specified
in one of the cells - defined as "fname" within the macro.

If this path does not exist on someones drive is there a way of creating the
required folders?

TIA

Matt
 
Back
Top