Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Creating folders

Here is another way to do that:

Sub CreateReportsFolder()
Dim RptPath As String
RptPath = Worksheets("SystemVariables").Range("ReportsFolder ").Text
On Error Resume Next
mkdir(rptpath)
On error goto 0
End sub

This assumes that only the right most directory might not exist. - a
limitation on the scripting approach as well.

--
Regards,
Tom Ogilvy


"Damien McBain" wrote:

Peter wrote:

Are there any excel wizards out there who could tell me how to get VBA
to create folders?


This checks to see if a folder exists already, then creates it if it
doesn't. The range called "ReportsFolder" is a cell on a worksheet with a
concatenation formula based on data the user has entered:

Sub CreateReportsFolder()

Dim NewFolder As Object
Dim RptPath As String
RptPath = Worksheets("SystemVariables").Range("ReportsFolder ").Text
Set NewFolder = CreateObject("Scripting.FileSystemObject")

If Not CBool(Len(Dir(RptPath))) Then
NewFolder.CreateFolder (RptPath)

Else

End If

End Sub

I "stole" the logic from VBA help in excel :)

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
Creating List From Folders Don Excel Programming 12 August 11th 06 12:47 AM
Help with Creating folders on Save Alarmbloke Excel Discussion (Misc queries) 3 December 22nd 05 06:00 PM
Creating folders using VBA Fred Smith Excel Programming 2 May 8th 05 03:27 PM
Creating folders with VB Foss Excel Programming 2 February 24th 04 10:08 AM
Creating Folders from Excel Using OLE Automation Bob C. Excel Programming 5 December 6th 03 03:57 PM


All times are GMT +1. The time now is 07:53 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"