At A Loss: Click Save - Saves To Multiple Locations

MACanada

New Member
Joined
Jan 15, 2014
Messages
2
Hey guys,

This is my first time posting on the forum but I've been following the posts for quite some time. Im a novice Macro user and took the first step by looking through all of the old posts. Here is what Im trying to do but Im really struggling.

1. When a user clicks the save button or presses the save disk the excel file is saved to two locations. I don't want to use a macro command button as the individuals using the tool will definitely forget.
C:\Users\g068716\Desktop\Drop\Dropbox\Ancaster\
C:\Users\g068716\Desktop\Personal\

2. When it saves it doesn't ask if its ok to overwrite the file. Just overwrite and save.

I've looked through piles of examples and the ones that look promising just dont seem to work. Here is what I have right now.

Sub Main()
'All saves should be placed between display alert toggle
Application.DisplayAlerts = False

ActiveWorkbook.SaveAs Filename:="C:\Users\g068716\Desktop\Drop\Dropbox\Ancaster\Book3.xlsm"
ActiveWorkbook.SaveAs Filename:="C:\Users\g068716\Desktop\Personal\"
Application.DisplayAlerts = True
End Sub

It successful overwrites without being asked if it wants to overwrite the current file which is great but it still requires a command button whereas Im looking for it to activate when the user selects File -> Save or Clicks the save disk.

Thanks in advance. I've really been stuck on this for a while.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Open your VB editor and double click on ThisWorkbook in the projects pane. Copy the procedure below into the ThisWorkbook code module. When you click save, it will run the procedure.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'All saves should be placed between display alert toggle
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Users\g068716\Desktop\Drop\Dropbox\Ancaster\Book3.xlsm"
ActiveWorkbook.SaveAs Filename:="C:\Users\g068716\Desktop\Personal\"
Application.DisplayAlerts = True
Cancel = True
End Sub
 
Last edited:
Upvote 0
JLG,

I opened the VB editor, double clicked on the workbook for Book3.xlsm which brought me to the module and pasted the code in. I saved the code and went back to the workbook. When I selected File - Save or simply clicked the Save Disk on the ribbon it did not save or update in either location.

Am I doing something wrong or does the code need to be adjusted?

Thanks,
 
Upvote 0

Forum statistics

Threads
1,215,269
Messages
6,123,976
Members
449,138
Latest member
abdahsankhan

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