Comment puis-je save le file excel à l'aide du code vba pour que le nom d'user et la date soient joints dans une macro?
Voici le code sur lequel j'ai travaillé pour essayer de le faire fonctionner:
ActiveWorkbook.SaveAs FileName:=(Environ$("Username")) & "_" & Date & "_BKMtracker.xlsx", FileFormat:=xlOpenXMLWorkbook
Essaye ça:-
ActiveWorkbook.SaveAs FileName: = (Environ $ ("Nom d'user")) & "_" & Date & "_BKMtracker.xlsx", FileFormat: = xlOpenXMLWorkbook
Avec crédit à @MatthewD
Sub SaveDocument() Dim username As Ssortingng Dim nowFormated As Ssortingng Dim path As Ssortingng Dim filename As Ssortingng Dim extention As Ssortingng username = Environ("Username") & "_" 'gets the username nowFormated = CStr(Format(now, "yymmdd")) 'or every format you like path = "D:\" 'Wherever you want to save the file filename = "_BKMtracker" 'or what you want extention = ".xlsm" 'for example (with macros, else you have to change the FileFormat too) ActiveWorkbook.SaveAs filename:=path & username & nowFormated & filname & extention, _ FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False End Sub