Microsoft KB Archive/292263

= XL97: How to Turn Off Automatic Font Scaling in All Charts =

PSS ID Number: 292263

Article Last Modified on 5/13/2002

-

The information in this article applies to:


 * Microsoft Excel 97 for Windows

-



This article was previously published under Q292263



SUMMARY
In Microsoft Excel 97, there is a limit of 256 fonts that can be used by the program. Charts that use the automatic scale feature have two fonts instead of one. This article explains how to programmatically turn the automatic scale feature off in all charts in a workbook.



How to Programmatically Turn Off Automatic Font Scaling
Microsoft 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 professionals 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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

http://www.microsoft.com/partner/referral/

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

 Start Excel. Click Tools, point to Macro, and then click Visual Basic Editor (or press ALT+F11). On the Visual Basic Editor Insert menu, click Module.  Type or paste the following code in the module: Sub C Dim ws As Worksheet, co As ChartObject, i As Integer Dim ch As Chart For Each ws In ActiveWorkbook.Worksheets

' Go through each worksheet in the workbook

For Each co In ws.ChartObjects

'In each chart turn the Auto Scale font feature off i = i + 1 co.Chart.ChartArea.AutoScaleFont = False Next co   Next ws

For Each ch In ActiveWorkbook.Charts

'Go through each chart in the workbook

ch.ChartArea.AutoScaleFont = False i = i + 1 Next MsgBox i & &quot; charts have been altered&quot; Application.DisplayAlerts = True End Sub  Click anywhere in the code of function C, and then click Run Sub/UserForm on the Run menu. After the macro runs, you should be able to insert a chart without error.

&quot;Not Enough Memory&quot; Error Message
If you attempt to add a chart to a workbook that would cause the number of fonts to exceed 256, you will receive an error message similar to the following:

Not enough memory.

This problems was corrected in Microsoft Office 97 Service Release 2 (SR-2). For additional information about running out of memory because of auto-scaling fonts, click the article number below to view the article in the Microsoft Knowledge Base:

168650 XL97: Not Enough Memory Error When You Add Chart to Workbook

Additional query words: XL97

Keywords: kbhowto KB292263

Technology: kbExcel97Search kbExcelSearch kbExcelWinSearch kbZNotKeyword3

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© 2004 Microsoft Corporation. All rights reserved.