Microsoft KB Archive/98177

= Microsoft Knowledge Base =

Excel: FOPEN Macro Fails when More Than Eight Channels Open
Last reviewed: September 12, 1996

Article ID: Q98177

The information in this article applies to:


 * Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0
 * Microsoft Excel for OS/2, versions 2.2, 3.0
 * Microsoft Excel for the Macintosh, versions 2.x, 3.0, 4.0, 5.0

SYMPTOMS
In Microsoft Excel, you can only open eight channels at a time with the FOPEN macro function. If you try to open a ninth channel with the FOPEN function, you will receive a macro error and your macro will halt.

MORE INFORMATION
Unlike the OPEN function, FOPEN does not actually open a file. FOPEN establishes a channel with the file, allowing you to use commands, such as FREAD and FWRITE, to read and write information to and from the file. The FOPEN command returns a value from 0 to 7; this number is the file ID of the FOPEN channel that has just been established.

By design, FOPEN only allows eight channels to be open at any one time. If you wish to use FOPEN to open a channel to another file, you must use the FCLOSE function to terminate one of the other channels. For example, to close a channel with a file ID of 5, you would use the following macro command:

=FCLOSE(5)

Microsoft Excel for Windows Only
In Microsoft Excel for Windows, the number of channels that you can open with the FOPEN function is dependent on the number of MS-DOS file handles you have available. If you do not have enough file handles available, you may not be able to open the full eight channels.

Note: You will never be able to open more than eight channels with FOPEN, regardless of how many file handles you have.