![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 01:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com