The following will allow you to save a folder of Word documents in a number
of common formats. The numbers are those associated with the particular file
types and not an indication that I cannot count
Sub SaveAllAsType()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim Response As Long
Dim fDialog As FileDialog
Dim sTypeNo As Integer
Dim sExt As String
sTypeNo = InputBox("Save documents in which format?" & vbCr & _
" 0 = Microsoft Office Word format." & vbCr & _
" 2 = Microsoft Windows text format." & vbCr & _
" 4 = Microsoft DOS text format." & vbCr & _
" 5 = Microsoft DOS text with line breaks preserved." & vbCr & _
" 6 = Rich text format (RTF)." & vbCr & _
" 8 = Standard HTML format." & vbCr & _
"10 = Filtered HTML format." & vbCr & vbCr & _
"Enter the number associated with the file type", "File Type",
2)
Select Case sTypeNo
Case Is = "0"
sExt = ".doc"
Case Is = "2"
sExt = ".txt"
Case Is = "4"
sExt = ".txt"
Case Is = "5"
sExt = ".txt"
Case Is = "6"
sExt = ".rtf"
Case Is = "8"
sExt = ".html"
Case Is = "10"
sExt = ".html"
Case Else
MsgBox "Incorrect number selected", vbExclamation
Exit Sub
End Select
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"
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
Set oDoc = Documents.Open(strPath & strFileName)
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & sExt
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=sTypeNo
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
End Sub
http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>