View Single Post
 
Old 11-26-2017, 11:09 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Do you mean the .txt file closes because the docx file already was closing:

Code:
Sub saveastxt()
Dim RetVal As Object
Dim strDelete As String
Dim strName As String
    On Error Resume Next
    ActiveDocument.Save
    If ActiveDocument.Path = "" Then
        MsgBox "Document not saved!"
        GoTo lbl_Exit
    End If
    strDelete = ActiveDocument.FullName
    strName = Replace(ActiveDocument.FullName, ".docx", ".txt")
    ActiveDocument.SaveAs2 FileName:=strName, FileFormat:=wdFormatText
    ActiveDocument.Close 0
    'RetVal = Shell("notepad.exe " & strName, 1) 'Don't open the saved .txt file
    Kill strDelete
lbl_Exit:
    Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote