Help and Support

WD: AppleScript Example: Close Command

Article ID:125580
Last Review:November 23, 2006
Revision:2.2
This article was previously published under Q125580
On This Page

SUMMARY

The information in this article discusses the following AppleScript event:

   Close
				


This event is found in the Core Suite of Word's Event Dictionary.

Back to the top

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:
https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104)
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)
The Core Suite contains events that a program should support to facilitate easy, intuitive communications between the program and the system software. System 7.0 was the first operating system to support these events.

The Close command is used to Close documents within Microsoft Word. The syntax for this command is listed below. The words enclosed by the [] symbols specifies an optional argument for the Close command.

   Close 'something' [Saving ] [Saving In]
				


The Saving argument can have three values Yes - Will save the document before closing it. No - Will not save the document before closing it. Ask - Will prompt the user to either save or not save before closing the document.


The Saving In argument is the path you want the document to be saved to. If you change the file name in this path, the document will be saved under a different name.


Back to the top

Example



The following AppleScript script sample demonstrates the Close event.

tell application "Microsoft Word"
   open "MyWordFile"
   set selection to first word
   delete selection
   close "MyWordFile" Saving ask saving in "WordCopy"
				
end tell

This script does the following:

1.Opens the document named "MyWordFile".
2.Selects the first word in the document.
3.Deletes the word.
4.Closes the document and asks whether you want to save or discard the changes before you close the document. It also saves the document using the file name, "WordCopy."

Back to the top


APPLIES TO
Microsoft Word 6.0 for Macintosh
Microsoft Word 6.01 for Macintosh
Microsoft Word 98 for Macintosh

Back to the top

Keywords: 
kb3rdparty kbdtacode kbinfo kbmacro kbmacroexample kbprogramming KB125580

Back to the top

Article Translations

 

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.