Excel: Error at Macro Cell Containing FOPEN Command

Last reviewed: November 2, 1994
Article ID: Q52180

SUMMARY

The FOPEN command function is designed to allow you to open a text file from a macro. If you try to run the FOPEN macro a second time, you will receive a "Macro error at cell..." error message. This is because the macro is unable to open a file that has already been opened using the FOPEN command.

Once a file has been opened by the FOPEN command, you can read and edit characters from the file. When finished, the file should be closed using the FCLOSE command. The following lines print the characters on the screen and then close the text file again:

             A
   1   =FOPEN("Worksheet1",1)
   2   =FREAD(A1,5)
   3   =ALERT(A2,2)
   4   =CLOSE(A1)
   5   =RETURN()

MORE INFORMATION

For more information on FOPEN, FCLOSE, and all the other F-commands, see pages 73 and 78-79 in the "Microsoft Excel Function Reference" version 3.0 manual. If you are using Excel 2.20, see pages 219 and 229-231 in the "Microsoft Excel Functions and Macros" version 2.2 manual.


KBCategory: kbother
KBSubcategory:

Additional reference words: 2.20 3.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.