0
Thanks

A few words of thanks would be greatly appreciated.

Excel - A macro to auto-save documents



Issue


I need a macro to automatically save my document, upon closing Excel.

Solution


Consider that ModèleGen and Onglet1 are variable strings.
Sub SauveEnX()  
    With Workbooks(ModèleGen).Sheets(Onglet1)  
        Nom_facture = .[A19] & " - " & .[G19] & " - " & .[T10] & ".xlsx"  
    End With  
    Application.DisplayAlerts = False  
    Workbooks(ClasseurEnTravail).SaveAs Filename:=RepSauve & Nom_facture, _  
        FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False  
    ActiveWorkbook.Close SaveChanges:=False 
    MsgBox Nom_facture & Chr(13) & Chr(13) & " sauvegardée !"  
    Application.DisplayAlerts = True  
End Sub

Thank to lermite222 for this tip.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by jak58.

This document, titled "Excel - A macro to auto-save documents," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments