Utiliser winmerge 2.14.0.0 dans le code VBA
Bonjour,
Après avoir recherché sur ce forum (et d'autres dont celui de WinMerge), je n'ai pas trouvé de réponse, même approximative. Je veux comparer 2 fichiers de type texte en utilisant WinMerge. J'arrive à ouvrir WinMerge mais je bute systématiquement sur un message de la boite "Select Files or Folders" : Both paths are invalid !
J'ai essayé beaucoup de choses mais je ne comprends pas d'où ça peut venir ... Quelqu'un connait-il cet usage ?
Valeurs de mes variables dans le contexte :
ArgsWinMerge = " -u -s "
LeftStringWinmerge = ""C:\Dossiers\Service_clients\Projet_PERSEPHONE\Specification\Outils\Applications\Migration\Migration_Tool\92001702 (Mon client test 92001072)\PERS20200401185958\ref\com\acx.bat""
RightStringWinmerge = ""C:\Dossiers\Service_clients\Projet_PERSEPHONE\Specification\Outils\Applications\Migration\Migration_Tool\92001702 (Mon client test 92001072)\PERS20200401185958\solution\com\acx.bat""
StringCommand = ""C:\Program Files (x86)\WinMerge\WinMergeU.exe" -u -s "C:\Dossiers\Service_clients\Projet_PERSEPHONE\Specification\Outils\Applications\Migration\Migration_Tool\92001702 (Mon client test 92001072)\PERS20200401185958\ref\com\acx.bat" "C:\Dossiers\Service_clients\Projet_PERSEPHONE\Specification\Outils\Applications\Migration\Migration_Tool\92001702 (Mon client test 92001072)\PERS20200401185958\solution\com\acx.bat"
Mon code VBA :
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim LeftStringWinmerge As String
Dim RightStringWinmerge As String
Dim ArgsWinMerge As String
Dim StringCommand As String
Dim ApplicationWinMerge As Object
Dim ErrReturnCode As Integer
On Error Resume Next
'== Chemins
Set wkb = ThisWorkbook
wkbPath = Left(wkb.Path, InStrRev(wkb.Path, "\") - 1) 'wkb.Path
CliName = ThisWorkbook.Sheets("Chiffrage").Range("C2") & " " & ThisWorkbook.Sheets("Chiffrage").Range("C3")
ProjectCode = ThisWorkbook.Sheets("Chiffrage").Range("C4")
LocalPathRef = wkbPath & "\" & CliName & "\" & ProjectCode & "\ref\"
LocalPathSolution = wkbPath & "\" & CliName & "\" & ProjectCode & "\solution\"
LocalPathRefCom = LocalPathRef & "com\"
LocalPathCliCom = LocalPathSolution & "com\"
'== WinMerge existe ? -> appel fonction
If FichierExiste("C:\Program Files (x86)\WinMerge\WinMergeU.exe") = True Then
ArgsWinMerge = " -u -s "
Set ApplicationWinMerge = CreateObject("WScript.shell")
'== Ouvrir winmerge sur double-clic dans une cellule
If Target.Row > 1 And Target.Column = 4 Or Target.Column = 8 Then
If ActiveCell.Offset(0, -3).Value2 <> "" Then
If ActiveCell.Offset(0, -1).Value2 = "CLIDIFF" Then
Select Case ActiveCell.Offset(0, -2).Value2
Case "Batch"
LeftStringWinmerge = Chr(34) & LocalPathRefCom & ActiveCell.Value & Chr(34)
RightStringWinmerge = Chr(34) & LocalPathCliCom & ActiveCell.Value & Chr(34)
StringCommand = Chr(34) & "C:\Program Files (x86)\WinMerge\WinMergeU.exe" & Chr(34) & ArgsWinMerge &
LeftStringWinmerge & " " & RightStringWinmerge & Chr(34)
ErrReturnCode = ApplicationWinMerge.Run(StringCommand, 1, True)
Set ApplicationWinMerge = Nothing
Case "Objets SQL" '-> à compléter
End Select
Else
MsgBox "La catégorie doit être CLIDIFF pour effectuer une comparaison", vbInformation, "Information"
End If
End If
End If
' WinMerge n'est pas trouvé
Else
MsgBox "Le programme WinMerge n'est pas installé sur votre poste, veuillez ouvrir un ticket auprès du support DSI", vbCritical + 512, "Attention"
End If
' Message final
If ErrRetCode <> 0 Then
MsgBox "Une erreur " & ErrReturnCode & " s'est produite, recommencez l'opération...", vbCritical + vbExclamation, "Alerte !"
End If
End Sub