Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check for a tab if it is exist Farhad Excel Discussion (Misc queries) 2 December 21st 08 07:31 PM
How to check if a folder/directory exist using VBA wellie Excel Programming 1 March 1st 04 02:24 AM
Check if pivot already exist Paul Wright Excel Programming 0 September 11th 03 05:45 AM
Check if pivot already exist Tom Ogilvy Excel Programming 0 September 11th 03 05:43 AM
check if a worksheet exist - VBA Warren Excel Programming 1 September 10th 03 05:02 AM


All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"