The following will save the current document as DOC with the same filename
(apart from the extension) and in the same folder
Sub SaveAsDoc()
Dim strDoc As String
Dim intPos As Integer
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".doc"
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocumentDefault
End Sub
and the following will convert all the TXT files in a folder to DOC
Sub SaveAllTxtAsDoc()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim bConv As Boolean
sConv = Options.ConfirmConversions
Options.ConfirmConversions = False
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
strPath = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count > 0 Then
Documents.Close savechanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.txt")
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".doc"
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocumentDefault
oDoc.Close savechanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
Options.ConfirmConversions = sConv
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>