View Single Post
 
Old 02-01-2018, 08:45 AM
gerison gerison is offline Windows 10 Office 2016
Novice
 
Join Date: Nov 2017
Posts: 8
gerison is on a distinguished road
Default

Hello again! You've been right, for notepad.

But I'm coming back to that issue, beacause I can't ajust it to my needs and make it work. I used the save to txt and open in notepad as a example to keep it simple and understand the process.

In the end I ajusted the scribt to my needs, which are: convert to .tex and open it in a Tex Editor.

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", ".tex")
    ActiveDocument.SaveAs2 FileName:=strName, FileFormat:=wdFormatText
    ActiveDocument.Close 0
    RetVal = Shell("C:\Program Files (x86)\Texmaker\texmaker.exe " & strName, 1) 'Don't open the saved .txt file
    Kill strDelete
lbl_Exit:
    Exit Sub
End Sub
It works, but only without any spaces in the filname. Otherwise the editor opens, showing no file, or in case of another editor: it opens with the massage, file not found. I tried several tex editors, all mention the same problem.

I just can't get it solved by myself. I simply don't understand why it works with notepad and not with the other editors.

I really would appreciate any help, and I'm willed to donate for a solution
Reply With Quote