ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to: check if folder exist, if not, create (https://www.excelbanter.com/excel-programming/303632-how-check-if-folder-exist-if-not-create.html)

escorido[_2_]

How to: check if folder exist, if not, create
 
Hello to all,

How to check if the folder exist in the ActiveWorkbook.Path directory
if it doesn't, create the folder there?

Could anyone show some sample codes on how to do this?
I'm still new to ExcelVBA and not familiar with it.

Thanks a lot

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


AA2e72E

How to: check if folder exist, if not, create
 
The code is:

Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long

Sub CreateFolder()
MakeSureDirectoryPathExists Application.DefaultFilePath & "\YOURFOLDER\"
End Sub

where \YOURFOLDER\ is the name of the folder whose existence you want to ensu note trailing \.


"escorido " wrote:

Hello to all,

How to check if the folder exist in the ActiveWorkbook.Path directory,
if it doesn't, create the folder there?

Could anyone show some sample codes on how to do this?
I'm still new to ExcelVBA and not familiar with it.

Thanks a lot!


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



Tom Ogilvy

How to: check if folder exist, if not, create
 
On error resume next
mkdir ActiveWorkbook.Path & "\myfolder"
On Error goto 0

--
Regards,
Tom Ogilvy

"escorido " wrote in message
...
Hello to all,

How to check if the folder exist in the ActiveWorkbook.Path directory,
if it doesn't, create the folder there?

Could anyone show some sample codes on how to do this?
I'm still new to ExcelVBA and not familiar with it.

Thanks a lot!


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





All times are GMT +1. The time now is 12:19 PM.

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