saving/creating a directory

  • Thread starter Thread starter mudraker
  • Start date Start date
M

mudraker

sPath$ = "c:\Temp"
If Dir(sPath, vbDirectory) = "" Then
MkDir (sPath)
End I
 
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
 

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