SaveAs Method Example

This example saves the active document as Test.rtf in rich-text format (RTF).

ActiveDocument.SaveAs FileName:="Text.rtf", FileFormat:=wdFormatRTF

This example saves the active document in text-file format, with the file name extension ".txt".

myDocname = ActiveDocument.Name
pos = InStr(myDocname, ".")
If pos > 0 Then
    myDocname = Left(myDocname, pos - 1)
    myDocname = myDocname & ".txt"
    ActiveDocument.SaveAs FileName:=myDocname, _
        FileFormat:=wdFormatText
End If

This example retrieves the SaveFormat property value for the WordPerfect 6.x converter, and then it uses this value with the SaveAs method.

For Each cnv In Application.FileConverters
    If cnv.ClassName = "WrdPrfctWin" Then
        ActiveDocument.SaveAs FileName:="MyWP.doc", _
            FileFormat:=cnv.SaveFormat
    End If
Next cnv

This example saves MyDoc.doc with a write password and then closes the document.

With Documents("MyDoc.doc")
    .SaveAs WritePassword:="pass"
    .Close
End With