PC Review


Reply
Thread Tools Rate Thread

Create New Folder Using Code

 
 
=?Utf-8?B?TmlnZWw=?=
Guest
Posts: n/a
 
      22nd May 2007
I run a series of spreadsheets for daily reports every morning, what I would
love to have happen is the following

when the first report runs it will create a folder in the main reports
folder (which is called reports) the folder name needs to be the current
date(format mmddyyyy)

when the next report runs it needs to look and see if the folder for the
current day exists and if so move on, otherwise create the folder (just in
case I run a report early to check data)


 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      22nd May 2007
Nigel,

Try something like this:


Sub test()
Dim strMainFolder As String
Dim strFolder As String

strMainFolder = "D:\REPORTS\"
strFolder = Format(Now, "mmddyyyy")

If Dir(strMainFolder & strFolder, vbDirectory) = "" Then
MkDir strMainFolder & strFolder
End If

End Sub


--
Hope that helps.

Vergel Adriano


"Nigel" wrote:

> I run a series of spreadsheets for daily reports every morning, what I would
> love to have happen is the following
>
> when the first report runs it will create a folder in the main reports
> folder (which is called reports) the folder name needs to be the current
> date(format mmddyyyy)
>
> when the next report runs it needs to look and see if the folder for the
> current day exists and if so move on, otherwise create the folder (just in
> case I run a report early to check data)
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      22nd May 2007

On Error Resume Next
MkDir "C:\Main Reports\" & Format(Date,"mmddyyyy")
On Error goto 0

maybe better to do yyyymmdd for sorting purposes.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Nigel" <(E-Mail Removed)> wrote in message
news:570F9600-3BE3-4D19-81CA-(E-Mail Removed)...
>I run a series of spreadsheets for daily reports every morning, what I
>would
> love to have happen is the following
>
> when the first report runs it will create a folder in the main reports
> folder (which is called reports) the folder name needs to be the current
> date(format mmddyyyy)
>
> when the next report runs it needs to look and see if the folder for the
> current day exists and if so move on, otherwise create the folder (just in
> case I run a report early to check data)
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create folder macro or vb code? Sherri Microsoft Excel Programming 3 13th May 2009 07:41 PM
Code to create folder and subfolders JP Microsoft Excel Programming 4 2nd Nov 2007 07:16 PM
create a folder useing vb code? zoneal@yahoo.com Microsoft VB .NET 4 17th Aug 2006 12:45 PM
How to create new folder by code =?Utf-8?B?Uml0YUs=?= Microsoft VB .NET 3 2nd Mar 2005 01:03 AM
Need code to create folder and copy files for install Dan Microsoft Access VBA Modules 1 9th Oct 2004 09:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:08 AM.