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: 157
Default Creating a folder automatically

Hi,

2 weeks back I started with VB by copying codes from this newsgroup and
trying out to make some sense of VB.

I came across a post a few hours back from RPIJG (Msgbox question...) in
which the person is automatically saving a file with a filename based on
some predetermined conditions.

Luckily I was in need of this and for my situation it works perfectly fine
based on sllight modifications.

My query is is it possible to create a folder if the folder doesnt exist.

For ex. My code is :-

Sub Writingfilenames()

Dim chosenname As String
Dim todaysformatteddate As String
Windows("ADSS-01.txt").Activate
foldername = Sheets("ADSS-01").Cells(3, 14)
filename = Sheets("ADSS-01").Cells(3, 4)
ActiveWorkbook.SaveAs Filename:="C:\CCAPPS\ttlview\TMP\" & foldername & "\"
& filename, FileFormat:=xlNormal

End Sub

In this I have a particular file by the name ADSS-01 -- A text (tab
limited) file.This file comes by exporting data from a program ( using its
export to spreadsheet option)

I want to rename this file based on what is there in the cell D3 hence the
varaible chosen name picks the value from D3.

Also I want to save the file in a particular folder whose name will be
today's date. That is if todays' date is "09-Jun-04" then I want to save it
in the folder
09-Jun-04. For this in the cell N2 of ADSS-01 I have used a formula
Text(today(),"dd-mmm-yy") and Im doing a paste special of this in
the cell N2. So, the foldername is picked up from cell N#.

My problem is it could happen that the folder name specified above may not
exist.

I was thinking whther the above code could be modified such that if folder
name doesnt exist then a folder ( whose name will be determined by the value
in
Sheets("ADSS-01").Cells(3, 14) ) could be created automatically.

Please tell me if the same is possible.

Regards,
Hari
India



 
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
Creating a folder on SaveAs leerem Excel Discussion (Misc queries) 6 December 8th 08 12:51 PM
Macro creating folder and files automatically, without permission. pokdbz Excel Discussion (Misc queries) 1 November 8th 07 04:24 PM
Creating a folder dan Excel Discussion (Misc queries) 5 September 27th 07 04:12 PM
Creating a new folder that does not already exsit. Ryan Excel Discussion (Misc queries) 3 July 16th 07 10:10 PM
creating folder Lawson Excel Programming 1 December 3rd 03 01:16 AM


All times are GMT +1. The time now is 12:17 AM.

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"