Auto saving & auto naming file - changing path of folder

rrmando

Board Regular
Joined
Dec 23, 2004
Messages
212
Hello party people. I was provided with some code that works great (auto saving to desktop and auto naming file), but now I am trying to customize it by end user:


Sub SaveMe()
Dim NewName As String
NewName = Sheets("Sheet1").Range("A1") & " - " & Sheets("Sheet1").Range("B1")

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\All Users\Desktop\" & NewName & ".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Application.DisplayAlerts = True
End Sub


Instead of saving to the desktop of all users, I want it to save to a folder on the desktop of a specific user. I have changed "C:\Documents and Settings\All Users\Desktop\" to read "C:\Documents and Settings\aportillo\Desktop\PO" to save to the folder PO that's on the desktop (not a shortcut) of user aportillo, but it still saves right to the desktop and adds the word PO to the beginning of the file name. I thought it was as simple as just changing the path name to make it save differently. What I am doing wrong? Thank you.
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,028
Turn on the macro recorder (Tools | Macro > Record new macro...) and save a file using the GUI in the appropriate folder. Turn off the recorder, switch to the VBE and check the XL generated code.

You may also want to check out a product such as Jan Karel Pieterse Autosafe add-in at http://www.oaltd.co.uk/MVP/MVPPage.asp#JanKarelPieterse Fair warning: I have no experience with it or with any other auto save program.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,337
Messages
5,601,026
Members
414,422
Latest member
acegreen

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