save workbook

benj

New Member
Joined
Feb 8, 2005
Messages
21
hi to all,
the problem i'm facing is that i hv a workbook(WB1) with a button on it. A macro is assigned to the button such that on click, it will activate some functions, including adding a new workbook(WB2). After everything calculation is done, I'm supposed to save WB2 into the directory where WB1 is saved and further save it into a sub directory -- C:\WB1.path\subdir\WB2.xls. As such, how can I write the VBA code for this function?

i know that i can use WB1.path to get the directory for WB1. However from what i know, when i wan to save a workbook to the 'subdir' i will need to use mkdir to create that directory beforehand. How can i incorporate everything into one function.

anyone pls advise.

thx a million
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Store the new directory name to a string variable, say MyPath.

Then:

MkDir MyPath
ChDir MyPath

Now the save will default to the new directory
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

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