Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Test for Folder Path. if it doesn't exist, Create it

Thank you sir, it worked.

Adnan


"Chip Pearson" wrote:

If you use the code at www.cpearson.com/Excel/BrowseFolder.aspx to display
the dialog, you can use code like the following,

Sub AAA()
Dim FName As String
FName = BrowseFolder("Choose A Folder")
If Len(FName) < 0 Then
Worksheets("Sheet1").Range("A1").Value = FName
End If
End Sub


Where BrowseFolder is the procedure that displays the folder dialog.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Adnan" (donotspam) wrote in message
...
Ron,

How do you write such code to call Dialog box to retrieve a folders path
and
input the path into cell A1 in Sheet1 (assuming there's a button next to
this
cell that would call this dialog)?

I thank you for sharing your expertise with us,
Adnan



"Ron de Bruin" wrote:

Hi Barb

You can find code on this page to test
http://www.rondebruin.nl/exist.htm

One way is this

Sub Test_Folder_Exist_FSO_Late_binding()
'No need to set a reference if you use Late binding
Dim FSO As Object
Dim FolderPath As String

Set FSO = CreateObject("scripting.filesystemobject")

FolderPath = "C:\My Folder"
If Right(FolderPath, 1) < "\" Then
FolderPath = FolderPath & "\"
End If

If FSO.FolderExists(FolderPath) = False Then
FSO.CreateFolder (FolderPath)
Else
MsgBox "Folder exist"
End If

End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Barb Reinhardt" wrote in
message
...
I'd like to test for a folder path (Z:\FolderName) and if it doesn't
exist,
I'd like to create it. Can someone provide a snippet of code on how to
do
this?

Thanks,
Barb Reinhardt




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
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k[_40_] Excel Programming 6 August 11th 06 08:41 PM
Create Folder If It Doesn't Exist Neutron1871 Excel Programming 4 May 6th 05 01:42 AM
How to: check if folder exist, if not, create escorido[_2_] Excel Programming 2 July 9th 04 01:28 PM
Test if folder exists, create if it doesn't? 43fan Excel Programming 1 March 1st 04 04:31 PM
Test if a folder exists, create if it doesn't? 43fan Excel Programming 3 March 1st 04 02:59 PM


All times are GMT +1. The time now is 12:04 PM.

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"