Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Create New Folder Using Code

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)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Create New Folder Using Code

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)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Create New Folder Using Code


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" wrote in message
...
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
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
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
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM
Create Folder / Copy Folder / Replace Murray Outtrim[_2_] Excel Programming 0 February 24th 04 06:40 PM
Create Folder..... Paiolas Excel Programming 1 September 17th 03 06:39 PM


All times are GMT +1. The time now is 09:45 AM.

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

About Us

"It's about Microsoft Excel"