Create dummy file structure?

R

Ray

I'm working on a template that will house several types of data --
some inputted directly into the workbook, other data being linked to
multiple external workbooks. When I say 'multiple', I'm thinking one
for every day of the year!

In order to make the links to these external workbooks, I'd like to
first create the exact file structure -- users can simply then 'save-
as' over top of the existing workbook. Is there a way to create this
file structure using VBA? That is, can I have Excel repeatedly 'save-
as' the current workbook, using the date as the file name?

The desired path would look like this:
\\server\folder1\folder2\StoreName\January1.xls
\\server\folder1\folder2\StoreName\January2.xls
\\server\folder1\folder2\StoreName\January3.xls
\\server\folder1\folder2\StoreName\January4.xls
etc....

Ideas?

TIA, Ray
 
T

Tom Ogilvy

spath = "\\server\folder1\folder2\StoreName\"
Thisworkbook.SaveAs sPath & format(date,"mmmmd") & .xls

It might be better to use


Thisworkbook.SaveAs sPath & format(date,"mmmmdd") & .xls
 
R

Ray

spath = "\\server\folder1\folder2\StoreName\"
Thisworkbook.SaveAs sPath & format(date,"mmmmd") & .xls

It might be better to use

Thisworkbook.SaveAs sPath & format(date,"mmmmdd") & .xls

Thanks Tom ... but how do I get the macro to scroll through each date
to create the files? In other words, I want to create all 365 files
today!

I'm thinking that I could enter the dates in cells A1:A365, but I'm
not sure how to modify your code to make Excel progress down the
column, saving a new file for each date?

ray
 
T

Tom Ogilvy

Sub ABC()
Dim spath as String, i as Long, dt as Date
spath = "\\server\folder1\folder2\StoreName\"
for i = 1 to 365
dt = dateserial(2007,1,i)
Thisworkbook.SaveAs sPath & format(dt,"mmmmd") & .xls
Next
End Sub
 
R

Ray

Sub ABC()
Dim spath as String, i as Long, dt as Date
spath = "\\server\folder1\folder2\StoreName\"
for i = 1 to 365
dt = dateserial(2007,1,i)
Thisworkbook.SaveAs sPath & format(dt,"mmmmd") & .xls
Next
End Sub

Works perfectly ... thanks Tom!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top