Saving multiple Files with a User Form


Posted by Kurt Lyons on December 09, 2001 12:43 PM

I'm developing a program that needs to save 8 similarly named files. The Macro creates 4 of the files at a time. Then, on the next run, makes the other four. So far I have been able to save the files using a defalt name. However, the poor user needs to go into the folder and rename the files individually.

Rather than having to do a "Save As" for each file seperatly I want to make it so the User sets the Core name of the file once then the program adds the different extentions. Example:

The User Sets the name for all 8 folders to be:
"R12 STC 12_9_01"

The first batch of files get named:
"R12 STC 12_9_01 VIC1.syn"
"R12 STC 12_9_01 FAM1.syn"
"R12 STC 12_9_01 FWD1.syn"
"R12 STC 12_9_01 REV1.syn"

Then on the second run the program will use the same name to save the new files as:
"R12 STC 12_9_01 VIC2.syn"
"R12 STC 12_9_01 FAM2.syn"
"R12 STC 12_9_01 FWD2.syn"
"R12 STC 12_9_01 REV2.syn"

If anyone can help me on this I'd VERY much appriciate it!
Thanks in advance.
Kurt



Posted by Bariloche on December 09, 2001 8:22 PM

Kurt,

Here are some concepts that you'll use to get where you're headed.

You need to get the CoreName from the user:

CoreName = InputBox ("Please provide a core file name")

You'll need a counter to keep track of the number of times you've gone through the file creation process, if you don't already have one. You also might need a counter (a different one, of course) to keep track of which file you're creating.

Then I'd suggest you use a Select Case construction. The whole thing would look basically like this:


Select Case FileCounter

Case Is = 1

FileName = CoreName & "VIC" & ProcessCounter & ".syn"

Case Is = 2

FileName = CoreName & "FAM" & ProcessCounter & ".syn"

and so forth for your other two files. The Select Case is closed out with the line:

End Select

Using two loops (the process one and the file one) you should be able to create as many files of the styles you indicated as you'd like.


have fun