Private Sub CommandButton4_Click()
Dim NomPicture As String
Dim Picture1 As Variant
Dim Doss As String
Dim Drive As String
Dim Monrep
Dim MaLigne As String
MaLigne = ""
'Gestion d'erreur
On Error GoTo 0
Sheets("DB").Activate
Nombre_ligne_sharecopter = Range("A" & Rows.Count).End(xlUp).row
MaLigne = Nombre_ligne_sharecopter + 1
numero = Range("A" & Nombre_ligne_sharecopter)
referenceA3 = Left(numero, 8)
referenceA2 = Left(numero, 9)
referenceA1 = Left(numero, 10)
val_ref = Len(numero)
val_referenceA1 = Len(referenceA1)
referenceB = Right(numero, val_ref - val_referenceA1)
referenceB = referenceB + 1
If referenceB >= 10 Then
reference = referenceA2 & referenceB
ElseIf referenceB >= 10 Then
reference = referenceA3 & referenceB
Else
reference = referenceA1 & referenceB
End If
Drive = "\\alpilles\x4$\predev\18-Support\B. DISCIPLINES & PSO ACTIVITIES\02. MATURITY\01. Maturity Management\database_draft\images\"
Doss = reference
If Dir(Drive & Doss, vbDirectory) = "" Then MkDir Drive & Doss
Picture1 = Application.GetOpenFilename( _
FileFilter:="Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP", _
Title:="Sélectionnez une image à sauvegarder")
NomPicture = Right(Picture1, Len(Picture1) - InStrRev(Picture1, "\")) 'trouve le nom du fichier
FileCopy Picture1, "Z:\B. DISCIPLINES & PSO ACTIVITIES\02. MATURITY\01. Maturity Management\database_draft\images\&reference\" & NomPicture 'Copie du fichier dans l'autre emplacement