ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   saving/creating a directory (https://www.excelbanter.com/excel-programming/288440-saving-creating-directory.html)

mudraker[_112_]

saving/creating a directory
 
sPath$ = "c:\Temp"
If Dir(sPath, vbDirectory) = "" Then
MkDir (sPath)
End I

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

saving/creating a directory
 
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.



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"mudraker " wrote in message ...
sPath$ = "c:\Temp"
If Dir(sPath, vbDirectory) = "" Then
MkDir (sPath)
End If


---
Message posted from http://www.ExcelForum.com/




Matt B

saving/creating a directory
 
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




All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com