LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save file in a new folder, but create folder only if folder doesn't already exist?


I am trying to generate reports and save the files in a folder, but I
want to create the folder if it does not already exist. If it does
exist, I want it to just save the file there. Right now I am just
setting it to make a directory, which was fine, but if I have other
reports going to that same folder and the folder already exists, I get
a "Path/File Access error" Is there a little line of code I can put in
that first checks to see if the folder exists?

Thanks,

~J

MyDate = Trim(VBA.Format(Now(), "MM-DD-YY"))
Application.DisplayAlerts = False
MkDir "G:\Reports\Friday Reports\" & MyDate
ActiveWorkbook.SaveAs filename:="G:\Reports\Friday Reports\" & _
MyDate & "\" & filename


--
nbaj2k
------------------------------------------------------------------------
nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
View this thread: http://www.excelforum.com/showthread...hreadid=570801

 
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
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
open file from folder save in new folder tim64[_3_] Excel Programming 20 June 17th 05 07:58 PM
"Save As" folder -- can I default this to the same folder as origi Mike Excel Discussion (Misc queries) 1 June 11th 05 12:06 AM
Create Folder If It Doesn't Exist Neutron1871 Excel Programming 4 May 6th 05 01:42 AM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM


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