Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Create new directory

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Create new directory

mkDir "C:\Datefile\" & format(sheets("MainPage").range("C22").Value, _
"yyyy-mm-dd")

Off the top of my head that should be close.
--
HTH...

Jim Thomlinson


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Create new directory

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Create new directory

Sebastien brings up an interesting point. If the value in C22 is a text
string then use his code to replace the slashes with dashes. If however, as I
had assumed, the value is a date then the replace will not work and my code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create new directory

Jim,

The text property of a range object is a text string, even if the value is a
date. It returns the cell as formatted. Your way is better though IMO as it
formats the date year first, which is better for sorting.

Bob

"Jim Thomlinson" wrote in message
...
Sebastien brings up an interesting point. If the value in C22 is a text
string then use his code to replace the slashes with dashes. If however,

as I
had assumed, the value is a date then the replace will not work and my

code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a

cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile

folder.

Thanks in advance.

Francis.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Create new directory

I didn't notice that Sebastien had used Text... I just assumed Value (which I
always use). I never use text for stuff like that because my end users like
to change formats and such on me. I guess that my end users are a little more
fiendish and clever than I would like... I will have to be more careful in
the future...

Nice catch Bob
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

Jim,

The text property of a range object is a text string, even if the value is a
date. It returns the cell as formatted. Your way is better though IMO as it
formats the date year first, which is better for sorting.

Bob

"Jim Thomlinson" wrote in message
...
Sebastien brings up an interesting point. If the value in C22 is a text
string then use his code to replace the slashes with dashes. If however,

as I
had assumed, the value is a date then the replace will not work and my

code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a

cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile

folder.

Thanks in advance.

Francis.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Create new directory

This Method worked.

Regards and Thanks.

Francis.

"Jim Thomlinson" wrote:

mkDir "C:\Datefile\" & format(sheets("MainPage").range("C22").Value, _
"yyyy-mm-dd")

Off the top of my head that should be close.
--
HTH...

Jim Thomlinson


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create new directory

It is quite a useful property to have up your sleeve Jim.

I still prefer your method :-))

Bob


"Jim Thomlinson" wrote in message
...
I didn't notice that Sebastien had used Text... I just assumed Value

(which I
always use). I never use text for stuff like that because my end users

like
to change formats and such on me. I guess that my end users are a little

more
fiendish and clever than I would like... I will have to be more careful in
the future...

Nice catch Bob
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

Jim,

The text property of a range object is a text string, even if the value

is a
date. It returns the cell as formatted. Your way is better though IMO as

it
formats the date year first, which is better for sorting.

Bob

"Jim Thomlinson" wrote in message
...
Sebastien brings up an interesting point. If the value in C22 is a

text
string then use his code to replace the slashes with dashes. If

however,
as I
had assumed, the value is a date then the replace will not work and my

code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a

cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in

C:/Datefile
folder.

Thanks in advance.

Francis.






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Create new directory

Sebastienm;
I wonder if you can help me to setup this macro. I want to create a
directory when I save as my file. My macro (see below) save as the file under
specific directory. However, I want to create a directory with the same
filename which is the description typed in the cell "C1" on the the sheet
"Test" and put my file under this new directory.
Could you please help me with this matter.
Thanks in advance.

Maperalia



'*** START MACRO *****
Sub SaveAs()
Dim WO As String

Set swApp = Application.SldWorks
Set swApp = GetObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

WO = Worksheets("Test").Range("C1")
longstatus = Part.SaveAs3("C:\Table\Top\ " & WO & ".sldprt", 0, 2)
End Sub
'*** END MACRO *****

"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.

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
Create Directory Structure from Cell Value. [email protected] Excel Discussion (Misc queries) 0 December 3rd 07 09:02 PM
Create a Backup in Different Directory [email protected] Excel Discussion (Misc queries) 1 August 2nd 05 09:27 PM
Pemission to create a directory fred Excel Programming 2 March 3rd 05 11:03 AM
Save to directory and create if not exist Rob Excel Programming 8 January 29th 05 05:39 PM
Create directory Soniya[_2_] Excel Programming 1 January 13th 04 01:36 PM


All times are GMT +1. The time now is 06:09 PM.

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"