Saving files to specific location VBA

lionelnz

Well-known Member
Joined
Apr 6, 2006
Messages
571
Hi everybody.

I need generic code to add a new workbook & save it using a filename format & for some reason the code below is not working.

What I am trying to do ultimately is, from a master annual workbook,
add a new workbook to a subfolder named after the relevant month (03 for March etc) & save to that folder as "DC" & mm (march would be DC03). This file is known as the monthly master as there could be up to 10 CSV files per month to be consolidated into the master monthly.

I then do other things with these montly files to consolidate into annual file but for the moment I have this key problem & this is what I have

Code:
Set NewBook = Workbooks.Add
            With NewBook
                .Title = "DC08" & mnth
                .Subject = "DC"
                .SaveAs Filename:="C:\Documents and Settings\New Owner\My Documents\AT\BNZ TransactionsHist\08DC\" _
                & mnth & "\" & "DC08" & mnth
            End With

It won't save the file to the folder I am trying to nominate by user input called "mnth". So I want create a master file for the month & save that file in the monthly folder.

My code works as separate operations but there is still a bit of automation I can do as one coding operation.

I also need this as I have 2 other operations I do monthly that will use this code.

Cheers for any help
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Re: Saving files to specific location VBA -Solved

Had to use ChDir command with string variables for fName & fPath.
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

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