In this article, we plan to show you 3 quick methods to delete a document or its contents in Word as required.
It’s a good habit to clean up your computer by removing useless documents. While deleting files, here are 2 situations you will meet:
- Sometimes, we can easily determine whether a document is unneeded with a glance at its name.
- Other times, we have no choice but open document and check its contents before finally discard it.
The following 3 methods shall list solutions to the foresaid situations into which you would possible run.
Method 1: Delete a Closed Document
- To start with, click “File” tab.
- Next click “Open” to trigger the same name window.
- Then go to the target folder and select a useless document.
- Right click on the document and choose “Delete”.
- Click “Yes” in confirmation box.
Method 2: Delete an Open Document
Normally, we can’t delete an open document. Yet, we find it’s too annoying that each time a document has to be closed before deletion. To address this issue, we suggest you take the macro way.
- First and foremost, you click “Developer” tab.
- Click “Visual Basic” next to open invoke VBA editor. Or just press “Alt+ F11” to do so.
- Next click “Insert” and then choose “Module” to insert a new one under “Normal” project.
- Then double click the module to open editing space on the right side.
- Paste the following macro:
Sub DeleteOpenDoc() Dim objDoc As Document Dim strDocName As String Dim strButtonValue As String ' Initialization Set objDoc = ActiveDocument strDocName = ActiveDocument.FullName ' Check if the doc has beed saved. If objDoc.Path = "" Then MsgBox ("This document hasn't been saved.") Exit Sub End If ' Deletion confirmation strButtonValue = MsgBox("Are you sure to delete " & strDocName & "?", vbYesNo) If strButtonValue = vbYes Then objDoc.Close SaveChanges:=wdDoNotSaveChanges KillFile = strDocName Kill KillFile End If End Sub
- Click “Run”.
- Now there will be a confirmation message on a popping up box. Click “Yes”.
Method 3: Delete Document Contents
There are also times you have saved a document with a name but want to discard all contents. Then the following macro is what you need:
Sub DeleteContents() Dim objDoc As Document Set objDoc = ActiveDocument objDoc.Content.Delete End Sub
Just follow the same steps in method 2 to install and run the macro.
What to do when Word goes wrong
When Word collapses, don’t freak out. Check your important file first and see if there is any corruption. If any, you can try the built-in tool first to recover data from damaged docx. The result, however, is not optimistic in most cases. Therefore, you probably will need a more sophisticated one.
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xls recovery and pdf repair software products. For more information visit www.datanumen.com