Low Memory Error with Repeated Use of WordBasic Dialog Record

Last reviewed: July 30, 1997
Article ID: Q98971
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0b, 2.0c

SUMMARY

If you use a WordBasic dialog record repeatedly, Word may generate an "Out of Memory" error message.

Each command in Word has different properties that define parameters for that particular command. For example, .LeftIndent and .Bold are properties of the FormatCharacter command. The entire set of properties is referred to as a dialog record. When this dialog record is repeatedly assigned to a command, an "Out of Memory" error eventually results. This does not happen if the properties are explicitly assigned.

MORE INFORMATION

The following two macros illustrate this problem. Although these macros are functionally identical, Macro1 will cause an "Out of Memory" error while Macro2 will not. Macro1 should only be run with a single blank document open. You must restart Word to restore memory after you run the macro.

Macro1

Sub MAIN
For I = 1 To 1000
   Print Str$(I)              'Display the counter on the status bar
   Dim fc As FormatCharacter  'Declare dialog record fc
   GetCurValues fc            'Get the current values
   FormatCharacter fc         'Assign them to FormatCharacter again
Next
End Sub

Macro2

Sub MAIN
For I = 1 To 1000
   Print Str$(I)
   Dim fc As FormatCharacter
   GetCurValues fc
   FormatCharacter .Font = "Times New Roman", .Points = "12", \
      .Bold = 0, .Italic = 0, .Strikeout = 0, .Hidden = 0, \
      .SmallCaps = 0, .AllCaps = 0, .Underline = 0, .Color = 0, \
      .Position = "0 pt", .Spacing = "0 pt"
Next
End Sub


KBCategory: kbmacro
KBSubcategory:
Additional query words: 2.0 2.0a 2.0b 2.0c winword winword2


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: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.