saep


Hello,

I have a macro that saves the current word document on the users c:\ and then emails it to me. I am aware of the kill function to delete a file, but I would need to close the file first in order to delete it - which can easily be done in the macro. But it appears that once Word closes the macro stops running.

Thanks for any help!




Re: Possible to run code after Word closes?

YellOwCN


u can open other word doc, and kill this one, no





Re: Possible to run code after Word closes?

magicalclick

How about save document as in C:\Export\, then, open up your origianl code document, then close the Exported document and invoke delete from the orignal document

But the easies way is to Creat a new workspace document when user opens your program. When user is done. Your program can then to whatever it wants and save the workspace and email and delete. Like yourCodeDocument.doc creates a new Temp.doc, save Temp.doc, email Temp.doc, and delete Temp.doc. Basically your code will affect external document, not itself.






Re: Possible to run code after Word closes?

saep

This is how it works:

Someone opens Template.doc which is saved as C:\ NewCreatedDocument.doc and then NewCreatedDocument is emailed. The problem is that now NewCreatedDocument is open and Template.doc is closed - just like when you do a "save as"

How can I save the document as NewCreatedDocument, but have Template.doc open and not NewCreatedDocument





Re: Possible to run code after Word closes?

magicalclick

Hello,

I just tested it. It is actually very simple, all you need to do is taking one more step.

Simply saved as the NewCreatedDocument back to Template. The code won't stop after saved as so, now, you are runing the code as Template instead of the NewCreatedDocument. This is the dirty approach. You may lose signature or alter the base template during the process. But I don't have experience on exporting document instead of save as.





Re: Possible to run code after Word closes?

saep

that is not a bad idea, but I want the original template document to remain empty, so saving the data in it is not acceptable.

I guess I'll have to clear all the form elements in the document and then save it