ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a new folder (https://www.excelbanter.com/excel-programming/361205-creating-new-folder.html)

cereldine[_33_]

Creating a new folder
 

Hi, I've written a code that pulls raw data into a variety of differen
workbooks, as this is happening i wuld also like to create an audi
trail which includes the original filename and todays date. I believ
that i can do this in some fashion already.

It would probably be best if when a new trail is created all th
associated files are saved in the same folder, preferabley with today
date. What is the best way to create a new folder from vba,

I was thinking something along the lines of

string1 = workbook.fullname and format(date)

mkdir string1

But ive also heard about filesys.createfolder ?

Has anyone else been faced with a similar task

--
cereldin
-----------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...fo&userid=3206
View this thread: http://www.excelforum.com/showthread.php?threadid=54115


Bob Phillips[_14_]

Creating a new folder
 
Go with MkDir. It is simple and works.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"cereldine" wrote
in message ...

Hi, I've written a code that pulls raw data into a variety of different
workbooks, as this is happening i wuld also like to create an audit
trail which includes the original filename and todays date. I believe
that i can do this in some fashion already.

It would probably be best if when a new trail is created all the
associated files are saved in the same folder, preferabley with todays
date. What is the best way to create a new folder from vba,

I was thinking something along the lines of

string1 = workbook.fullname and format(date)

mkdir string1

But ive also heard about filesys.createfolder ?

Has anyone else been faced with a similar task?


--
cereldine
------------------------------------------------------------------------
cereldine's Profile:

http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=541158




Barry-Jon

Creating a new folder
 
It sounds like you are referring to the Scripting runtimes
FileSystemObject. It is worth using as it wraps a lot of oft-needed
functionality in a very easy to use manner. To use it you need to
reference the library from the VBA editor by going to Tools -
References... From there you should find "Microsoft Scipting Runtime",
check the box and you're ready to go. An example of doing what you
wanted is below. I would highly recommend searching for
filesystemobject in the vba help - it's a great resource. Is this what
you were thinking of?

Sub CreateDirectory(Path As String)

Dim fso As Scripting.FileSystemObject

Set fso = New Scripting.FileSystemObject

fso.CreateFolder (Path)

End Sub



All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com