Excel VBA quit Word document

后端 未结 2 377
南旧
南旧 2021-01-19 03:03

I have a macro that inserts select cells of an Excel document into a Word template, copies the entire Word document then closes the document without saving, to preserve cert

相关标签:
2条回答
  • 2021-01-19 03:31

    I had the same problem. And only code below closed this Word window:

    Dim x As Variant
    
    X = Shell("powershell.exe kill -processname winword", 1)
    

    I found this code in one of the answers Closing word application from excel vba

    0 讨论(0)
  • 2021-01-19 03:33

    Please add the below to your code:

    appWd.Quit
    

    This would be between

    appWd.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
    

    and

    Set appWd = Nothing
    

    That calls the WinWord Quit method, which should solve your problem.

    0 讨论(0)
提交回复
热议问题