lizardking8610
6/29/2017 - 3:45 AM

Batch Convert Doc to Docx with VBA and Vice Versa and Doc to PDF Batch

Batch Convert Doc to Docx with VBA and Vice Versa and Doc to PDF Batch

Sub TranslateDocIntoDocx()
  Dim objWordApplication As New Word.Application
  Dim objWordDocument As Word.Document
  Dim strFile As String
  Dim strFolder As String

  strFolder = "E:\Temp\"
  strFile = Dir(strFolder & "*.doc", vbNormal)
  
  While strFile <> ""
    With objWordApplication      
      Set objWordDocument = .Documents.Open(FileName:=strFolder &strFile, AddToRecentFiles:=False, ReadOnly:=True, Visible:=False)
          
      With objWordDocument
        .SaveAs FileName:=strFolder & Replace(strFile, "doc", "docx"), FileFormat:=16
        .Close
      End With
    End With
    strFile = Dir()
  Wend   

  Set objWordDocument = Nothing
  Set objWordApplication = Nothing
End Sub
Sub TranslateDocIntoDocx()
  Dim objWordApplication As New Word.Application
  Dim objWordDocument As Word.Document
  Dim strFile As String
  Dim strFolder As String

  strFolder = "C:\Users\Computer\Documents\pdfs\"
  strFile = Dir(strFolder & "*.doc", vbNormal)
  
  While strFile <> ""
    With objWordApplication
      Set objWordDocument = .Documents.Open(FileName:=strFolder & strFile, AddToRecentFiles:=False, ReadOnly:=True, Visible:=False)
          
      With objWordDocument
        .SaveAs FileName:=strFolder & Replace(strFile, "doc", "pdf"), FileFormat:=17
        .Close
      End With
    End With
    strFile = Dir()
  Wend

  Set objWordDocument = Nothing
  Set objWordApplication = Nothing
End Sub
Sub TranslateDocxIntoDoc()
  Dim objWordApplication As New Word.Application
  Dim objWordDocument As Word.Document
  Dim strFile As String
  Dim strFolder As String

  strFolder = "E:\Temp\"
  strFile = Dir(strFolder & "*.docx", vbNormal)
   
  While strFile <> ""
    With objWordApplication  
      Set objWordDocument = .Documents.Open(FileName:=strFolder & strFile, AddToRecentFiles:=False, ReadOnly:=True, Visible:=False)
     
      With objWordDocument
        .SaveAs FileName:=strFolder & Replace(strFile, "docx", "doc"), FileFormat:=0
        .Close
      End With
    End With
    strFile = Dir()
  Wend

  Set objWordDocument = Nothing
  Set objWordApplication = Nothing
End Sub