Utilisateur anonyme
-
15 sept. 2004 à 16:57
Utilisateur anonyme -
15 sept. 2004 à 17:55
Bonjour,
Je souhaite créer l'enregistrement d'un classeur Excel dans un répertoire bien défini.
Mais avant je souhaiterais savoir si un fichier portant le même nom existe...pour ne pas l'écraser.
Je ne sais pas si j'ai bien été clair...
Path = ActiveWorkbook.Path
Sheets("Maquette").Select
Sheets("Maquette").Copy
ActiveWorkbook.SaveAs Filename:=Path & "\toto.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
Message = MsgBox("Le fichier à été enregistré sous le nom suivant" & Chr(13) & Path & "toto.xls",vbinformation)
jrivet
Messages postés7392Date d'inscriptionmercredi 23 avril 2003StatutMembreDernière intervention 6 avril 201260 15 sept. 2004 à 17:14
salut,
ajoute la reference Windows Script Host Object Model.
Tu pourra utiliser le FileSystemObject comme suit:
Dim fs as new filesystemobject
Sheets("Maquette").Select
Sheets("Maquette").Copy
if fs.fileexists(Path & "\toto.xls") then
msgbox "le fichier existe deja"
else
ActiveWorkbook.SaveAs Filename:=Path & "\toto.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
Message = MsgBox("Le fichier à été enregistré sous le nom suivant" & Chr(13) & Path & "toto.xls",vbinformation)
end if
@+
-------------------------------------------------
Essai ca sinon on trouvera autre chose
-------------------------------------------------