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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default 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


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
searching by number or code ina work book justsomeguy Excel Discussion (Misc queries) 0 February 19th 07 08:55 PM
Searching, matching then searching another list based on the match A.S. Excel Discussion (Misc queries) 1 December 13th 06 05:08 AM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM


All times are GMT +1. The time now is 02:10 AM.

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

About Us

"It's about Microsoft Excel"