Create Copy File/Workbook When Click Save (VBA)

ybr_15

Board Regular
Joined
May 24, 2016
Messages
166
Hi dear,

I have a workbook (example: Report.xlsm) in my local computer. In this workbook, I want to run a vba code to create a copy every time I click the save button to certain directory in my server (example: \\192.168.0.6\Production\). So, I will have 2 Report.xlsm files, 1 in my local computer and 1 on the server. Can anyone help me how to do that? Thank you
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,338
.
Code:
Sub SaveMyWorkbook()
         
    Dim strPath As String
    Dim strFolderPath As String
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    strFolderPath = "C:\Users\My\Desktop\"
    strPath = "Backup.xlsm"
    ActiveWorkbook.SaveAs Filename:=strPath
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
     
End Sub

Change path and workbook name as required.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,303
Messages
5,486,061
Members
407,530
Latest member
Shameem Khan

This Week's Hot Topics

Top