最近的回覆,我知道。
另一種方式來做到這一點的人不熟悉VB腳本可能把這樣的事情在宏的結尾:
Sub DeleteCurrentDoc()
Dim Doc1 As Document
Dim Doc2 As Document
Dim deletepath As String
'While the document you want to delete is open and is the current 'Active Document'
Set Doc1 = ActiveDocument
'get path of this document to delete it later
deletepath = Doc1.FullName
'Add a new temporary blank document
Set Doc2 = Documents.Add
'Close the document we are going to delete
Doc1.Close False
'Delete it
Kill (deletepath)
'Clear away the temp doc we created
Doc2.Close False
'Tidy up and close Word (Optional Line, delete if necessary)
Application.Quit
End Sub
編輯:一種更輕的方式(測試字2013):
Sub DeleteCurrentDoc()
Dim Doc1 As Document
Dim deletepath As String
'get path of this document to delete it later
deletepath = ActiveDocument.FullName
'Close the document we are going to delete (Word should remain Open
ActiveDocument.Close False
'Delete it
Kill (deletepath)
'Tidy up and close Word (Optional Line, delete if necessary)
Application.Quit
End Sub