XL: WordBasic Command FileExit Generates An ErrorLast reviewed: December 1, 1997Article ID: Q123327 |
The information in this article applies to:
SYMPTOMSIn Microsoft Excel, you will receive the following error message if you use the WordBasic FileExit method in a macro that performs Automation with Microsoft Word:
Run-time error 545: The FileExit statement is currently disabled. CAUSEThe FileExit method of the WordBasic language cannot be invoked via Automation. Because Automation cannot start a new instance of Word after the initial instance, it assumes that you started Word and you are responsible for exiting the application.
WORKAROUNDMicrosoft 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 engineers 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.aspTo avoid receiving this error message, use the following code to set the Word object to Nothing rather than using the WordBasic FileExit command:
Sub WordOLE() Dim Word as Object ' Create the Word object. Set Word=CreateObject("Word.Basic") ' Start a new document in Word. Word.FileNew ' Insert the text "Some Text" on the new document in Word. Word.Insert "Some Text" ' Clear the Word object. Set Word = Nothing End Sub MORE INFORMATIONThe CreateObject function will start Word version 6.0 if it is not already running, otherwise it will use the currently-active instance of Word. The Set Word = Nothing statement will exit Word if Word was started by the CreateObject statement. In Microsoft Word version 6.0 for Macintosh, you can use FileQuit in place of FileExit. If you use the FileQuit command in a macro that performs OLE Automation with Word, you will receive the same results. You will receive the error message "The FileExit statement is currently disabled" if you use the following code which uses the WordBasic FileExit command:
Sub WordOLE() Dim Word as Object ' Create the Word object. Set Word=CreateObject("Word.Basic") ' Start a new document in Word. Word.FileNew ' Insert the text "Some Text" on the new document in Word. Word.Insert "Some Text" ' Attempt to quit Word. Word.FileExit End Sub REFERENCES"Visual Basic User's Guide," pages 189-198 For additional information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q108043 TITLE : How VB Can Use OLE Automation with Word Version 6.0 |
Additional query words: 5.00 6.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |