Re : création d'un fichier d'installation
On est jamais mieux servi que par soi-même :
J'ai finalement réussi à créer quelque chose de bien (en cherchant des éléments à droite à gauche ) :
Sub installation1()
Dim choixdossier$
Dim lesfichiers, AutresFichiers, Origine, Destination As String
Set FSO = CreateObject("Scripting.FileSystemObject")
Application.ScreenUpdating = False
choixdossier = ChDossier
choixdossier1 = choixdossier & "\test"
If choixdossier = "" Then Exit Sub
If Dir$(choixdossier1, vbDirectory) = "" Then
Else
Reponse = MsgBox("Le programme est déjà installé")' vérifie si le dossier existe ou pas
Exit Sub ' si il existe il ne continue pas
End If 'sinon, il continue
source = choixdossier
Origine = ThisWorkbook.Path & "/test"
If Origine = "" Then Exit Sub
Destination = source & "/test"
lesfichiers = Origine & "\" & "*.*"
Reponse = MsgBox("Confirmer le répertoire d'installation : " & choixdossier, vbYesNo + vbExclamation, "Installation")
If Reponse = vbYes Then
FSO.CopyFolder Origine, Destination
Else
Exit Sub
End If
End Sub
Private Function ChDossier() 'selection la destination du prog d'impôt
Dim objShell, objFolder, chemin, SecuriteSlash
Set objShell = CreateObject("Shell.Application")
Set objFolder = _
objShell.BrowseForFolder(&H0&, "Choisissez la destination du programme d'impôt", &H1&)
On Error Resume Next
chemin = objFolder.ParentFolder.ParseName(objFolder.Title).Path
If objFolder.Title = "Bureau" Then
chemin = "C:\"
End If
If objFolder.Title = "" Then
chemin = ""
End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then
chemin = Mid(objFolder.Title, SecuriteSlash - 1, 2) & ""
End If
ChDossier = chemin
End Function