H
Hari
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
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