Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default create a folder using a macro

Hello!

Part of a larger macro contains the following:

ChDir _
"C:\Documents and Settings\My Documents\Flashes\New"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My Documents\Flashes\New\Data Total.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

However, I actually want the macro to create a new folder, name it
something, and then proceed to save the workbook in the folder as Data Total.
Is it possible to do that? As it is right now, I have to create a folder
called "New" before running the macro, which isn't that hard, but it is a
small step in a series of steps that I always forget.

Any help would be apprieciated!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default create a folder using a macro

Hi
This code creates a folder as a subfolder of the one which contains the
active workbook. You could change this to some other path.
It first checks if the folder already exists. If it doesn't then the
folder is created. The DoEvents bit is just there to make sure the
folder exists before the next bit of VBA code runs.

regards
Paul

MyDirectory = ActiveWorkbook.Path & "\" & "Test Directory"
DirTest = Dir$(MyDirectory, vbDirectory)
If DirTest = "" Then
MkDir MyDirectory
DoEvents 'just make sure it is there
End If
ChDir MyDirectory

redb wrote:
Hello!

Part of a larger macro contains the following:

ChDir _
"C:\Documents and Settings\My Documents\Flashes\New"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My Documents\Flashes\New\Data Total.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

However, I actually want the macro to create a new folder, name it
something, and then proceed to save the workbook in the folder as Data Total.
Is it possible to do that? As it is right now, I have to create a folder
called "New" before running the macro, which isn't that hard, but it is a
small step in a series of steps that I always forget.

Any help would be apprieciated!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default create a folder using a macro

Thank you! That helps so much in this macro and several others I use.
Beautiful.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default create a folder using a macro

Hi,
Can you please let me know how to create a new folder with today's date.
I want to save the result of my macro in the folder. For example if i run the
macro in file abc.xls today in c:\macro folder, i want the result of that
macro to be saved in c:\macro\09292005\ folder with time stamp appended to
the file name (abc_10:30.xls). Is this possible. Please help me.

Thanks,
Mahesh

"redb" wrote:

Thank you! That helps so much in this macro and several others I use.
Beautiful.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default create a folder using a macro

Just what I needed! Thanks!

" wrote:

Hi
This code creates a folder as a subfolder of the one which contains the
active workbook. You could change this to some other path.
It first checks if the folder already exists. If it doesn't then the
folder is created. The DoEvents bit is just there to make sure the
folder exists before the next bit of VBA code runs.

regards
Paul

MyDirectory = ActiveWorkbook.Path & "\" & "Test Directory"
DirTest = Dir$(MyDirectory, vbDirectory)
If DirTest = "" Then
MkDir MyDirectory
DoEvents 'just make sure it is there
End If
ChDir MyDirectory

redb wrote:
Hello!

Part of a larger macro contains the following:

ChDir _
"C:\Documents and Settings\My Documents\Flashes\New"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My Documents\Flashes\New\Data Total.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

However, I actually want the macro to create a new folder, name it
something, and then proceed to save the workbook in the folder as Data Total.
Is it possible to do that? As it is right now, I have to create a folder
called "New" before running the macro, which isn't that hard, but it is a
small step in a series of steps that I always forget.

Any help would be apprieciated!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default create a folder using a macro

Thanks Paul. This code is really helpfull.

Maperalia

" wrote:

Hi
This code creates a folder as a subfolder of the one which contains the
active workbook. You could change this to some other path.
It first checks if the folder already exists. If it doesn't then the
folder is created. The DoEvents bit is just there to make sure the
folder exists before the next bit of VBA code runs.

regards
Paul

MyDirectory = ActiveWorkbook.Path & "\" & "Test Directory"
DirTest = Dir$(MyDirectory, vbDirectory)
If DirTest = "" Then
MkDir MyDirectory
DoEvents 'just make sure it is there
End If
ChDir MyDirectory

redb wrote:
Hello!

Part of a larger macro contains the following:

ChDir _
"C:\Documents and Settings\My Documents\Flashes\New"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My Documents\Flashes\New\Data Total.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

However, I actually want the macro to create a new folder, name it
something, and then proceed to save the workbook in the folder as Data Total.
Is it possible to do that? As it is right now, I have to create a folder
called "New" before running the macro, which isn't that hard, but it is a
small step in a series of steps that I always forget.

Any help would be apprieciated!



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
Macro to create a folder and copy files GainesvilleWes New Users to Excel 2 February 26th 07 06:33 PM
Macro to create a new folder according to the month Dolphin Excel Discussion (Misc queries) 5 December 15th 06 01:31 PM
How do I create a new folder using a macro rsabot Excel Programming 2 May 22nd 05 12:59 PM
Create folder with a macro Myrna Rodriguez Excel Programming 3 June 28th 04 10:34 PM
Macro to create folder yo beee Excel Programming 1 October 21st 03 02:10 AM


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