Provided you have Word 2007, then yes, you can batch process files with the
Word PDF creation tool.
If that tool is installed, the following macro will work with all documents
in doc or docx format in a folder selected from the macro. The macro will
throw an error if any of the documents are mail merge documents, but should
work fine with documents that contain simply text. If the documents are
plain text with a TXT extension then the macro will require some changes,
but we'll cross that bridge if required.
Sub SaveAllAsPDF()
Dim strFileName As String
Dim strDocName() As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "Save all as PDF"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFileName = Dir$(strPath & "*.doc")
While Len(strFileName) <> 0
WordBasic.DisableAutoMacros 1
Set oDoc = Documents.Open(strPath & strFileName)
strDocName = Split(oDoc.FullName, ".")
If ActiveDocument.SaveFormat = 0 Or _
ActiveDocument.SaveFormat = 12 Then
ActiveDocument.SaveAs _
FileName:=strDocName(0) & ".pdf", _
FileFormat:=wdFormatPDF
End If
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
WordBasic.DisableAutoMacros 0
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>