Low Memory Error with Repeated Use of WordBasic Dialog RecordLast reviewed: July 30, 1997Article ID: Q98971 |
The information in this article applies to:
SUMMARYIf 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 INFORMATIONThe 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 MAINFor 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 MAINFor 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |