iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 23
0
自我挑戰組

Access VBA 之 iT管理實做系列 第 23

Access VBA 之 iT管理實做Day23: 整合外部程式-DiffMerge

上一篇提到把資料轉出成純文字,再透過程式對照,來查看兩個不同MDB檔案的差異,今天就跟各位介紹一套軟體,搭配VBA使用上效果還不錯:

SourceGear DiffMerge
https://sourcegear.com/diffmerge/

筆者撰寫了VBA來呼叫此程式,因為此程式支援command-line模式,透過昨天介紹的轉出資料到文字檔的程式,轉成文字檔後,再丟到這個對照程式去查看差異,一氣呵成。

SourceGear_DiffMerge:

Sub SourceGear_DiffMerge(strPath1 As String, strPath2 As String, Optional strT1 As String = "NEW", Optional strT2 As String = "OLD")
' SourceGear DiffMerge 是一套用於對照檔案的程式
' 可以餵給它兩個資料夾,會自動對照兩個資料夾的內容差異
' https://sourcegear.com/diffmerge/

Dim strCMD As String
strProgram = "C:\Users\NTSVR6\Downloads\DiffMerge_4_2_0_697_stable_x86\sgdm.exe"

If InStr(strT1, " ") > 0 Then strT1 = Chr(34) & strT1 & Chr(34)
If InStr(strT2, " ") > 0 Then strT2 = Chr(34) & strT2 & Chr(34)
If InStr(strPath1, " ") > 0 Then strPath1 = Chr(34) & strPath1 & Chr(34)
If InStr(strPath2, " ") > 0 Then strPath2 = Chr(34) & strPath2 & Chr(34)

strCMD = strProgram & " /t1 " & strT1 & " /t2 " & strT2 & " " & strPath1 & " " & strPath2
'Debug.Print strCMD
RunCMD strCMD, False, False, 1

End Sub

如此一來可以很快速的找到差異的地方,以下是筆者用來處理工作用的MDB檔,可以快速的比較出兩個MDB檔資料表的內容差異:

有差異的檔案:
https://ithelp.ithome.com.tw/upload/images/20181107/200072215fBwQ3VL40.png

檔案內的數值差異:
https://ithelp.ithome.com.tw/upload/images/20181107/20007221Hl90QVo7f3.png


上一篇
Access VBA 之 iT管理實做Day22: 資料轉出成文字檔
下一篇
Access VBA 之 iT管理實做Day24: 自定義程式-顯示群組內容清單
系列文
Access VBA 之 iT管理實做30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言