![]() |
VBA code to searching for a folder
Hi,
I am new in VBA and i want to check for a folder and if the folder can not be find creat it. any sugestion would be appriciated. Thanks, -- Farhad Hodjat |
VBA code to searching for a folder
try the below code
'Declare File System object Dim oFSO As Scripting.FileSystemObject 'Initialize File System object Set oFSO = New Scripting.FileSystemObject 'Check if your desired folder exists If oFSO.FolderExists("H:\Test") Then Debug.Print "yes" Else 'Create your desired folder as it does not exist oFSO.CreateFolder "H:\Test" End If Before you use the above code make sure you have referred to MicroSoft Scripting Runtime from Tools--References HTH, -- Pranav Vaidya VBA Developer PN, MH-India If you think my answer is useful, please rate this post as an ANSWER!! "Farhad" wrote: Hi, I am new in VBA and i want to check for a folder and if the folder can not be find creat it. any sugestion would be appriciated. Thanks, -- Farhad Hodjat |
VBA code to searching for a folder
If Dir("C:\HopedForFolder\nul") = "" Then MkDir "C:\HopedForFolder"
-- Jim "Farhad" wrote in message ... | Hi, | | I am new in VBA and i want to check for a folder and if the folder can not | be find creat it. any sugestion would be appriciated. | | Thanks, | -- | Farhad Hodjat |
All times are GMT +1. The time now is 08:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com