Macro to save worksheet to a particular location

saraapple

Board Regular
Joined
Feb 3, 2020
Messages
144
Office Version
  1. 2010
Platform
  1. Windows
I have the following macro which works perfectly (all credit to this site :))

Dim NewName As String
Set Shts = ActiveWorkbook.Worksheets(Array("Delivery schedule Stoke", "Delivery schedule Meridian", "Salvage", "Suppliers"))

Shts.Copy

NewName = InputBox("Please Enter the name for the new workbook", "New Workbook Name")
With ActiveWorkbook
Sheets(Array("Suppliers", "SALVAGE")).Select
Sheets("Suppliers").Activate
ActiveWindow.SelectedSheets.Visible = False
.SaveAs (NewName & ".xls")
.Close savechanges:=True
End With
ThisWorkbook.Close savechanges:=False

End Sub

The only problem I have is it saves the new workbook in random places - can I change this to make it save in a particular folder.
I know I need to add the path to the code, but my attempt of:

Path = file:///\\prg-dc.dhl.com\uk\DSC\Sites\Dunelm\TRANSPORT-DRIVE-DO-NOT-MOVE\DHLMER-PLANNING\Richard\NEW%20%20Paragon%20Reporting\

Does not work!

Also with my current version of the macro (which seems to now save sheets in documents) I get an error message when opening the file:

1614075456822.png
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

fadee2

Active Member
Joined
Nov 7, 2020
Messages
367
Office Version
  1. 2019
Platform
  1. Windows
Edit:
It should be

Close true, strpath & newname & ".xls"

Since the file you are saving is an xls file....
 

Forum statistics

Threads
1,141,405
Messages
5,706,261
Members
421,437
Latest member
GijoeBlack

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
Top