Using winmerge 2.14.0.0 in VBA code

Open discussion about WinMerge.

Using winmerge 2.14.0.0 in VBA code

Postby Padawan » Tue Apr 28, 2020 11:26 am

Hello,

First, I'm french so, excuse me for my english. I want to compare 2 text files from an Excel workbook. Winmerge is openning but I've always a message in the "Select Files or Folders" window : Both paths are invalid !
I've tried many things but I don't understand where it can come from. Please, I need help !

Values of variables in run context :

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"

My VBA code :

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

'== Paths
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\"

'== Is WinMerge exists ?
If FichierExiste("C:\Program Files (x86)\WinMerge\WinMergeU.exe") = True Then
ArgsWinMerge = " -u -s "
Set ApplicationWinMerge = CreateObject("WScript.shell")

'== Open winmerge on double-clic cell
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" '-> to complete
End Select
Else
MsgBox "La catégorie doit être CLIDIFF pour effectuer une comparaison", vbInformation, "Information"
End If
End If
End If
' WinMerge isn't here
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
' Final message
If ErrRetCode <> 0 Then
MsgBox "Une erreur " & ErrReturnCode & " s'est produite, recommencez l'opération...", vbCritical + vbExclamation, "Alerte !"
End If

End Sub
Padawan
 
Posts: 1
Joined: Tue Apr 28, 2020 5:58 am

Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 9 guests