VBA variable save file as depending on folder path of another workbook

Lefemmenikita

Board Regular
Joined
Jan 28, 2014
Messages
59
Office Version
  1. 2013
Platform
  1. Windows
Hi

I have a workbook template ('master workbook') where I want to create new workbook from using one of Master workbook's worksheets.

i.e. right clicking the tab called 'summary'(in Master workbook)> move or copy worksheet> create new workbook:

PJsEcoc.png



I want to save the newly created workbook in the same place as the original workbook(('Master Workbook') from which it originated using a macro.

Is there a variation of this code which I can use so that it points to wherever the Master workbook is saved, and save the newly created workbook in the same location?


Code:
Dim Masterwb As Workbook
Dim folderpath As String


folderpath = Application.[B]ActiveWorkbook[/B].Path

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try
Code:
Workbooks("Master Workbook").Path
 
Upvote 0
Thanks.

Just to clarify, where do I use that line of code?

Wouldn't I need to declare what ("Master Workbook") is (as an object?) elsewhere?
 
Upvote 0
Is the macro located in the Master Workbook?
 
Upvote 0
In that case you can simply use
Code:
ThisWorkbook.path
 
Upvote 0

Forum statistics

Threads
1,215,784
Messages
6,126,878
Members
449,347
Latest member
Macro_learner

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