Results 1 to 2 of 2
Thread: Exit word (Word 2000)
2006-09-17, 18:22 #1
- Join Date
- Sep 2006
- Thanked 0 Times in 0 Posts
Exit word (Word 2000)
How can i write a macro on a word document, having the command to close the document with a cick ?
2006-09-18, 18:14 #2
- Join Date
- Feb 2001
- Silicon Valley, USA
- Thanked 93 Times in 89 Posts
Re: Exit word (Word 2000)
<P ID="edit" class=small>(Edited by jscher2000 on 18-Sep-06 12:14. )</P>The VBA macro code required to close the currently active document is simple:
There are options for what to do about unsaved changes. You can read up on these in the VBA help file. As you may know, the simplest way to access VBA help is to create a new macro:
- <LI>In your Word document, press Alt+F8 to open the Macros dialog
<LI>Type a name, such as <code>TestMacro</code>, to create it in a particular template or document, use the drop down control, then click Create
<LI>Type or paste the code of interest between Sub TestMacro and End Sub
<LI>Select an object, method, or property in the code and press F1
<UL><LI>The old way was a "macrobutton" field. This requires a double-click, and is tricky to use in a protected document (e.g., if your document is a protected form).
<LI>A newer way is a control from the controls toolbox. I actually haven't used these, so I'm not sure how easy they are to connect to a macro. Probably not too bad.
<LI>A third possibility is a document-specific toolbar, set to float around somewhere noticeable. I often do this for in-house solutions.[/list]Does that help?
Added: I just noticed the name of this thread is Exit Word. To close Word in VBA, you can try Application.Quit, but I'm not sure it actually works from inside Word. (Some testing will be required.)