0
我已經使用Word完成了一個文本比較宏,我需要循環它以便它可以比較幾組文檔。有關如何這樣做的任何想法? 這裏是我的代碼循環比較宏
Dim template1 As Word.Document
Dim spool1 As Word.Document
Set template1 = Documents.Open("D:\Users\tmp4jj\Desktop\ComparisonTool\template1.docx")
Set spool1 = Documents.Open("D:\Users\tmp4jj\Desktop\ComparisonTool\spool1.txt")
Application.CompareDocuments OriginalDocument:=Documents("template1.docx") _
, RevisedDocument:=Documents("spool1.txt"), Destination:= _
wdCompareDestinationNew, Granularity:=wdGranularityWordLevel, _
CompareFormatting:=False, CompareCaseChanges:=True, CompareWhitespace:= _
False, CompareTables:=True, CompareHeaders:=True, CompareFootnotes:=True, _
CompareTextboxes:=True, CompareFields:=True, CompareComments:=True, _
CompareMoves:=False, RevisedAuthor:="UOB", IgnoreAllComparisonWarnings:= _
False
ActiveWindow.ShowSourceDocuments = wdShowSourceDocumentsBoth
,我也做了一個文件計數宏,不知道它需要
Dim FolderPath As String, path As String, count As Integer
FolderPath = "D:\Users\tmp4jj\Desktop\ComparisonTool"
path = FolderPath & "\*.docx"
path = FolderPath & "\*.txt"
FileName = Dir(path)
Do While FileName <> ""
count = count + 1
FileName = Dir()
Loop
MsgBox count & " : files found in folder"
Windows("Document1").Activate
Application.Run MacroName:="FileCount"
Application.Move Left:=-3, Top:=-3
Application.Run MacroName:="FileCount"
Application.Move Left:=-3, Top:=-3
注意,'路徑= FOLDERPATH& 「\ * DOCX。」'沒有任何影響 – moffeltje