Deleting a Document while Opened

D

darkrats

Is this possible:

Open a Word 2000 document under Windows 2000.
Take a look at it, and decide that you want to delete it.

Find and click a menu item that deletes the document when you close it.


(or do you have to close the document, and then right-click on the icon and
delete it)


Thanks.
 
G

Greg Maxey

Rats,

Not extensively tested, but you might assign this macro to a menu,
icon, or keyboard shortcut:

Sub KillDoc()
Dim KillString As String
KillString = ActiveDocument.FullName
ActiveDocument.Close
FileSystem.Kill (KillString)
End Sub
 
G

Greg Maxey

Ron P,

I agree with your sequence. Tecnically the document must be closed
before it is deleted. However that sequence is effectively transparent
when using code similar to:

Sub KillDoc()
Dim KillString As String
KillString = ActiveDocument.FullName
ActiveDocument.Close
FileSystem.Kill (KillString)
End Sub


Which could be included in a global template and trigger by a menu,
icon, or keyboard shortcut.

To the user it would appear that the document was simply deleted (first
closed or not) ;-)
 
D

darkrats

Thanks for the code.

I don't know exactly how to assign it to an icon or menu, but I'll do some
"trial and error" experimenting, when I get home from work this evening.


darkrats
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top