0
선택한 폴더의 동일한 문서의 여러 버전을 비교하기 위해 Word에 Vba 스크립트를 만들었습니다. 스크립트를 사용하면 결과가있는 새 보고서를 만들 수 있습니다.Word vba 매크로에 프로세스 표시기 추가
Private Sub SummaryReportButton_Click()
Dim objDocA As Word.Document
Dim objDocB As Word.Document
Dim objDocC As Word.Document
Dim objFSO As Scripting.FileSystemObject
Dim objFolderA As Scripting.Folder
Dim objFolderB As Scripting.Folder
Dim objFolderC As Scripting.Folder
Dim colFilesA As Scripting.Files
Dim objFileA As Scripting.File
Dim i As Integer
Dim j As Integer
Set objFSO = New FileSystemObject
Set objFolderA = objFSO.GetFolder(ChooseFolder("Choose the folder with the original documents", ThisDocument.Path))
Set objFolderB = objFSO.GetFolder(ChooseFolder("Choose the folder with revised documents", ThisDocument.Path))
Set objFolderC = objFSO.GetFolder(ChooseFolder("Choose the folder for the comparisons documents", ThisDocument.Path))
Set colFilesA = objFolderA.Files
For Each objFileA In colFilesA
If objFileA.Name Like "*.docx" Then
Set objDocA = Documents.Open(objFolderA.Path & "\" & objFileA.Name)
Set objDocB = Documents.Open(objFolderB.Path & "\" & objFileA.Name)
Set objDocC = Application.CompareDocuments(_
OriginalDocument:=objDocA, _
RevisedDocument:=objDocB, _
Destination:=wdCompareDestinationNew)
objDocA.Close
objDocB.Close
On Error Resume Next
Kill objFolderC.Path & "\" & objFileA.Name
On Error GoTo 0
objDocC.SaveAs FileName:=objFolderC.Path & "\" & objFileA.Name
objDocC.Close SaveChanges:=False
End If
Next objFileA
End Sub
Function ChooseFolder(strTitle As String, strPath As String) As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = strTitle
.AllowMultiSelect = False
.InitialFileName = strPath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
ChooseFolder = sItem
Set fldr = Nothing
End Function
처리가 끝날 때까지 표시기를 표시하여 스크립트를 개선하고 싶습니다.
나는 메시지 상자 사용할 생각 :Msgbox "Processing " & i & " of " & colFilesA.Count
을하지만 할
당신이 좀 도와 주 시겠어요 ... 그것은 최선의 해결책이 아니다 ... 때마다 클릭해야합니다 최선의 해결책? 당신의 도움에 미리
감사합니다,
감사
단어 파일을 초래하는 문제 방금 저장하기 전에 몇 시간 동안 열립니다 (팝업 "저장중인 문서에 변경 사항 추적이 포함되어 있습니까?") 그리고이를 피하기 위해 구현하는 방법을 모르겠습니다. – coeurdange57
'Application.DisplayAlerts = False'는 속성을 다시 'True'로 설정할 때까지 시스템 경고를 표시하지 않습니다. 경고가 꺼져있는 동안 Word는 기본 응답을 선택합니다. 경고 상자에서 미리 선택된 버튼을 찾아서 기본값을 테스트 할 수 있습니다. – Variatus
'.ShowModal'을'False'로 설정 한 상태로'UserForm'을 삽입 할 수도 있습니다.이 폼은 필요시로드되며'Label'에서 진행 상황을 보여줍니다. – macejd