2017-01-17 6 views
1

나는 모두 호환 모드로 저장된 약 1200 개의 단어 문서가 들어있는 폴더가 있습니다. 문서가 더 이상 호환 모드가되지 않도록 이러한 파일을 모두 변환하는 방법을 알고있는 사람이 있습니까?1000+ 단어 문서의 호환 모드 제거

답변

0

폴더의 cmd 창을 열고 dir /s /b >> filename.txt를 입력하여 경로의 모든 파일에 대한 일반 텍스트 목록을 가져옵니다. 그러면 디렉토리의 모든 파일을 나열하는 텍스트 파일이 제공됩니다. 내가 당신이라면 1000 개 파일에 그것을 할거야 때문에 다음

의 입력으로, 나는 doc.close에서 브레이크 포인트를 설정합니다

사용은 처음 몇에 그것을 밖으로 테스트합니다.

Sub SaveAsDocX(FileListFullPath As String) 
    'for saving to new filename 
    Dim newname As String 
    'array of docs, items in that array, document object from those items 
    Dim docs As Variant 
    Dim item As Variant 
    Dim doc As Document 

    docs = getfiles(FileListFullPath) 

    For Each item In docs 
     If Right(item, 4) = ".doc" Then 
      Set doc = Application.Documents.Open(FileName:=item) 
      doc.Activate 

      newname = item & " - updated.docx" 

      'first save as new format then update compatibility, then save again 
      doc.SaveAs2 FileName:=newname, FileFormat:=wdFormatDocumentDefault 
      ActiveDocument.SetCompatibilityMode (wdCurrent) 
      doc.SaveAs2 FileName:=newname, FileFormat:=wdFormatDocumentDefault 

      doc.Close 
     End If 
    Next 
End Sub 



Function getfiles(Optional FileName As String = "Dir.txt") 
    Dim FileList() As String 

    Open FileName For Input As #1 
    FileList = Split(Input$(LOF(1), #1), vbCrLf) 
    Close #1 

    getfiles = FileList 

End Function