Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Error 28 out of stack space

I'm doing the simplest task - to fill a cell with a ctrl+a key with the
following code:

Sub PrintName()
'
' PrintName Macro
' Print Waterbury
' Keyboard Shortcut: Ctrl+a
'
ActiveCell.FormulaR1C1 = ""
Range("A1:D1").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Application.CommandBars("Stop Recording").Visible = False
Application.CommandBars("Task Pane").Visible = False
ActiveCell.FormulaR1C1 = "Waterbury"
Range("C2").Select
Application.Run "PERSONAL.XLS!PrintName" 'it stops here
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Monty\My Documents\Book1.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWindow.Close
Workbooks.Add
End Sub
It stops at line -Application.Run "Personal.XLS!PrintName" and highlights it
yellow. I get a run-time error 28: Out of stack space. It seems to be in a
continuous loop until it runs out of memory.
Any hints appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Error 28 out of stack space

Jim,

You are calling PrintName from inside of PrintName, which then calls
PrintName, which then ...

As you say, this is an endless loop. The error that you are seeing "out of
stack space" is another way to say that your code is stuck in an endless
loop.

The solution is to not call the routine from inside the routine.

hth,

Doug

"JIM" wrote in message
...
I'm doing the simplest task - to fill a cell with a ctrl+a key with the
following code:

Sub PrintName()
'
' PrintName Macro
' Print Waterbury
' Keyboard Shortcut: Ctrl+a
'
ActiveCell.FormulaR1C1 = ""
Range("A1:D1").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Application.CommandBars("Stop Recording").Visible = False
Application.CommandBars("Task Pane").Visible = False
ActiveCell.FormulaR1C1 = "Waterbury"
Range("C2").Select
Application.Run "PERSONAL.XLS!PrintName" 'it stops here
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Monty\My Documents\Book1.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWindow.Close
Workbooks.Add
End Sub
It stops at line -Application.Run "Personal.XLS!PrintName" and highlights
it
yellow. I get a run-time error 28: Out of stack space. It seems to be in
a
continuous loop until it runs out of memory.
Any hints appreciated.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of Stack Space error TheMilkGuy Excel Discussion (Misc queries) 2 July 22nd 09 05:54 PM
OUT OF STACK SPACE ERROR [email protected] Excel Programming 1 March 14th 08 10:24 AM
'Out of stack space' error on SaveAs Tim[_45_] Excel Programming 3 September 22nd 05 05:51 PM
Out of Stack Space error JimFor Excel Programming 2 December 26th 04 08:41 PM
Run time error 28: Out of stack space Will Wirtz Excel Programming 1 April 27th 04 01:39 PM


All times are GMT +1. The time now is 06:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"