XL97: "Not Enough Memory" Error Adding Chart to Workbook

ID: Q168650

The information in this article applies to:

This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.

SYMPTOMS

When you attempt to add a new chart to a workbook in Microsoft Excel 97, you may receive the following error message:

   Not enough memory.

If you are using a Visual Basic for Applications macro to add chart sheets to a workbook, you may also receive the following error message:

   Run-time error '1004':
   Method 'Add' of object 'Sheets' failed

CAUSE

This problem may occur if you add more than 124 charts to a workbook when editing the workbook in Microsoft Excel 97 or Microsoft Excel 97 SR-1.

Note that the limit of charts in the workbook may actually be fewer than 124, especially if you use multiple fonts in worksheets in your workbook or if you use embedded charts. Also, note that if the workbook contains charts that were added in earlier versions of Microsoft Excel, the workbook may contain more than 124 charts.

RESOLUTION

To correct this problem, obtain Microsoft Excel 97 Service Release 2 (SR-2) and perform the following steps:

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).

To resolve the problem, you can add a key to the registry that disables automatic font scaling for charts. To do this, follow these steps:

NOTE: Because there are several versions of Windows, the following steps may be different on your computer. If they are, please consult your product documentation to complete these steps.

1. Quit all running programs.

2. Click the Windows Start button, and then click Run.

3. In the Open box, type "regedit" (without the quotation marks), and

   then click OK.

4. Go to the following registry key:

      HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\Microsoft
         Excel

5. Point to New on the Edit menu, and then click String Value. Type
   "AutoChartFontScaling", without quotation marks, and then press
   ENTER.

6. Click Modify on the Edit menu. Type "0", without quotation marks, in
   the Value Data box, and then click OK.

7. Click Exit on the File menu to exit the Registry Editor.

The next time that you start Excel, you should be able to create more than 124 charts.

If you are unable to obtain Microsoft Excel 97 SR-2, you may be able to work around this problem by using either of the following methods:

Method 1: Turn Off the Auto Scale Option in Your Charts

1. Select the chart area.

2. On the Format menu, click Selected Chart Area.

3. Select the Font tab.

4. Clear (uncheck) the "Auto scale" checkbox.

5. Click OK.

Method 2: Move Charts into Another Workbook

You may also be able to work around this limitation by moving some of the charts in your workbook into another workbook. Charts moved to another workbook will remain linked to the data in the original workbook.

NOTE: If you remove embedded charts from a worksheet and add additional charts, the "Not enough memory" error message appears unless you first save, close, and then reopen the workbook. If you delete chart sheets or worksheets that contained embedded charts, you can then add new charts up to the limit without receiving the error message and without saving, closing, and then reopening the file.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Excel 97 for Windows. This problem was corrected in Microsoft Office 97 Service Release 2 (SR-2).

For additional information about SR-2, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q151261
   TITLE     : OFF97: How to Obtain and Install MS Office 97 SR-2

MORE INFORMATION

In Microsoft Excel 97, there is a limit of 256 fonts that may be used by the program. When you create a chart, the chart uses two fonts if the Auto Scale feature for that chart is enabled (this is the default behavior in Microsoft Excel 97). So, it is possible to exceed the limit of fonts by creating a workbook that contains the following objects:

   Objects                      Fonts per Object   Total Fonts Used
   ----------------------------------------------------------------
   124 chart objects            2 fonts                   248 fonts
   1 worksheet                  1 font                      1 font
   used by Microsoft Excel 97   6 fonts                     6 fonts
                                                  -----------------
                                                   Total  255 fonts

If you attempt to add a 125th chart to the workbook, the total number of fonts used would be 257. Because this would exceed the limit of 256 fonts, you receive a "Not enough memory" error message.

Turning off the Auto Scale feature for each chart may allow you to extend the maximum number of charts that may be added to the workbook.

Additional query words: 97 XL97

Keywords          : kberrmsg kbdta kbchart
Version           : WINDOWS:97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbbug

Last Reviewed: July 2, 1999