Question about saving a workbook with a macro

Colombo

Board Regular
Joined
Apr 21, 2003
Messages
54
I've got a question about saving a workbook with a macro. I can save the workbook fine with the macro. What I would like to do is have the macro generate the file name based upon a given text & add the month year into the title of the file name.

So for example, I want to save the file name as "Feb 2003 Monthly Report.xls"

Is there anyway to setup the macro to use the date function or something else to generate the Feb 2003 based upon the current month, or possibly by looking at a cell in the workbook?

Thanks in advance for any help.

Josh
 
LTunnicliffe said:
Narf...

Code:
if len(dir("C:\monthly reports\"))=0 then MkDir("C:\Monthly reports\")

Sorry, don't know what got into me.

LT

That gives the same error too. It works fine when the directory does not exist, but if it exists I get the error.
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Code:
if len(dir("C:\monthly reports\", 16))=0 then MkDir("C:\Monthly reports\")

Sorry about that it works for sure this time. :oops:
 
Upvote 0
LTunnicliffe said:
Code:
if len(dir("C:\monthly reports\", 16))=0 then MkDir("C:\Monthly reports\")

Sorry about that it works for sure this time. :oops:

That did it.

Thanks for all the help.

Just curious though. What exactly does the len function do, and what does the 16 on the back do? I searched through the visual basic help and didn't find any info on that particular parameter.

I really need to get a book or something that can give me a little more info and help on the fundamentals.

Josh
 
Upvote 0
The function len() returns the length of a string (ex. len("Cat") would be 3).

The 16 which I failed to get anytime before my last shot is a parameter of the dir() function, it tells the function that we're looking for a directory and not a file.

Hope these explanations are enough.

LT
 
Upvote 0
LTunnicliffe said:
The function len() returns the length of a string (ex. len("Cat") would be 3).

The 16 which I failed to get anytime before my last shot is a parameter of the dir() function, it tells the function that we're looking for a directory and not a file.

Hope these explanations are enough.

LT

Yup,

That's good, Thanks again.

Josh
 
Upvote 0

Forum statistics

Threads
1,221,711
Messages
6,161,450
Members
451,707
Latest member
PedroMoss2268

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top