PDA

View Full Version : save a file to a defined destination



sujittalukde
05-21-2007, 06:54 AM
I have a macro which saves the file at a particular destination. But a user can save the file to another location through normal save/save as function of excel. How normal save/save function can be restricted and / or even if user choose normal save/save as function the files will be saved to the defined particular path say D:\data

Bob Phillips
05-21-2007, 07:29 AM
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim sFile
Application.EnableEvents = False
ThisWorkbook.Save
Cancel = True
Application.EnableEvents = True
End Sub



This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code