![]() |
#1
|
|||
|
|||
![]()
I have one folder called "RAW" contains 30 .rtf files, and another folder called "NEW" contains 30 .rtf files with same name with the raw folder.
I can compare them one by one using the word compare option, but it is tedious. Can i have a method to compare them one by one automatically, and store all the compared files with editing mode in a third new folder? I have wrote a VBA macro, but it can not work accurately: ************************************************** *** Sub TFL_Review() Dim fldrVersion1 As String, fldrVersion2 As String Dim strVersion1 As String, strVersion2 As String Dim docVersion1 As Document, docVersion2 As Document Dim docCompareTarget As Document Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogFolderPicker) With fd .Title = "Select the folder that contains the original files." If .Show = -1 Then fldrVersion1 = .SelectedItems(1) Else MsgBox "You did not select a folder." Exit Sub End If End With With fd .Title = "Select the folder that contains the revised files." If .Show = -1 Then fldrVersion2 = .SelectedItems(1) Else MsgBox "You did not select a folder." Exit Sub End If MsgBox fldrVersion1 End With 'For i = 1 To 2 'fldrVersion1 = fldrVersion1 & "\Folder" & i & "" 'fldrVersion2 = fldrVersion2 & "\Folder" & i & "" fldrVersion1 = fldrVersion1 & "" fldrVersion2 = fldrVersion2 & "" MkDir fldrVersion2 & "Compared" strVersion1 = Dir$(fldrVersion1 & "*.rtf*") While strVersion1 <> "" 'Set docVersion1 = Documents.Open(strfldrVersion1 & strVersion1) 'Set docVersion2 = Documents.Open(strfldrVersion1 & docVersion1.Name) Set docVersion1 = Documents.Open(fldrVersion1 & strVersion1) Set docVersion2 = Documents.Open(fldrVersion1 & docVersion1.Name) docVersion1.Compare Name:=docVersion2, CompareTarget:=wdCompareTargetNew ActiveDocument.SaveAs2 fldrVersion2 & "Compared" & docVersion1.Name ActiveDocument.Close docVersion1.Close wdDoNotSaveChanges docVersion2.Close wdDoNotSaveChanges strVersion1 = Dir$() Wend 'Next i End Sub |
Tags |
vba compare word |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Edszx | Word VBA | 2 | 05-27-2019 11:16 PM |
Save Word as TXT File (per batch) | aarona | Word VBA | 0 | 07-07-2017 04:31 AM |
![]() |
equalizer88 | Word VBA | 3 | 08-16-2015 04:56 PM |
![]() |
QA_Compliance_Advisor | Word VBA | 11 | 09-11-2014 11:51 PM |
![]() |
romanticbiro | Office | 1 | 06-30-2014 06:04 PM |