Microsoft KB Archive/121442

WordBasic Error 55 with Kill Command

PSS ID Number: Q121442 Article last modified on 03-07-1997

=
========================================================= 2.00 2.00a 2.00a-cd 2.00b 2.00c WINDOWS kbprg kbusage

= SYMPTOMS =

When using the WordBasic Kill command following an InsertFile command, you will receive the following error:

WordBasic Err=55 File already open.

The following macro, for example, will return the above error:

Sub MAIN InsertFile .Name = “C:.doc” Kill “c:.doc” End Sub

This behavior also occurs when you copy the file to the Clipboard and then run the following macro after pasting the contents of the Clipboard.

Sub MAIN Kill “c:.doc” End Sub

= CAUSE =

Word does not allow you to delete files that are open. When you use the InsertFile command or copy a file to the Clipboard, Word holds a pointer to the file and releases this pointer when the file is saved and closed.

= RESOLUTION =

Modify the macro to include the FileSaveAs (or FileSave) and FileClose commands before executing the Kill command, as in the following example:

Sub MAIN InsertFile .Name = “C:.doc” ’name of file inserted FileSaveAs .Name = “test.doc” ’save document that you ’are inserting FileClose ’close file Kill “c:.doc” ’delete inserted file End Sub

KBCategory: kbprg kbusage KBSubcategory: kbmacro Additional reference words: 2.00 2.00a 2.00a-cd 2.00b 2.00c winword macro winword2 kill wordbasic error err 55 file already open ====================================================================== ============================================================================= Copyright Microsoft Corporation 1997.