Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to determine if a Folder/Directory Exists in Excel VBA

Hi All,

Does anybody know how i can determine if a directory exists in VBA? For
example i would like to write a function that looks to see if the path
c:\reports\2006 exists, if so leave it be, if not create it.

Thanks,
Bill

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to determine if a Folder/Directory Exists in Excel VBA

Why bother checking. Just ignore any errors that occur when you try to create
it:

on error resume next
mkdir "C:\reports"
mkdir "C:\reports\2006"
on error goto 0

(One level at a time.)

wrote:

Hi All,

Does anybody know how i can determine if a directory exists in VBA? For
example i would like to write a function that looks to see if the path
c:\reports\2006 exists, if so leave it be, if not create it.

Thanks,
Bill


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to determine if a Folder/Directory Exists in Excel VBA

Bill,
Dave's answer is native VBA, but there's also the API route:

<From API-Guide: URL: http://www.allapi.net/
Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll"
(ByVal lpPath As String) As Long

Private Sub Form_Load()
'create the directory "c:\this\is\a\test\directory\", if it doesn't exist
already
MakeSureDirectoryPathExists "c:\this\is\a\test\directory\"

End Sub
</From API-Guide:

NickHK

wrote in message
oups.com...
Hi All,

Does anybody know how i can determine if a directory exists in VBA? For
example i would like to write a function that looks to see if the path
c:\reports\2006 exists, if so leave it be, if not create it.

Thanks,
Bill



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
Folder/Directory listings saved in Excel? Paddy O''Moron Excel Discussion (Misc queries) 1 November 24th 09 04:25 PM
Check if folder exists, if yes just copy sheet in to folder? Simon Lloyd[_787_] Excel Programming 3 June 19th 06 03:44 PM
Determine if folder exists Terry K Excel Programming 1 June 9th 06 06:26 PM
If A Directory Exists Jim Thomlinson[_5_] Excel Programming 0 February 4th 06 09:00 PM
How does Excel determine the TEMP directory? Miso Excel Programming 3 July 31st 03 02:19 PM


All times are GMT +1. The time now is 09:06 PM.

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"