Hello,
When I run the following code on my Word Document:
Public Sub setTextColumns(ByRef LeDoc As Document)
Dim c As Long
Dim x As Range
For c = 2 To LeDoc.InlineShapes.Count - 1
Set x = LeDoc.Range( _
LeDoc.InlineShapes(c).Range.End + 1, _
LeDoc.InlineShapes(c + 1).Range.Start)
LeDoc.Range(Start:=LeDoc.InlineShapes(c).Range.End+1, _
End:=LeDoc.InlineShapes(c).Range.End). _
InsertBreak Type:=wdSectionBreakContinuous
LeDoc.Range(Start:=LeDoc.InlineShapes(c + 1).Range.Start, _
End:=LeDoc.InlineShapes(c + 1).Range.Start). _
InsertBreak Type:=wdSectionBreakContinuous
x.PageSetup.TextColumns.SetCount 3
Next c
I get, about 30 loops through, message saying "Not enough memory. When this action will finish, it will be impossible to undo. Continue?", to which I answer yes.
The problem is, at this point, my code stops running, and Word shuts down without further warning. I tried to check out exactly how many lines of code after the message prompt this happenned, but by adding Message Boxes to find out, the warning stopped appearing and Word didn'T crash.
Now, I know my problem is kind of fixed, but I'm jsut really confused as to WHY this happens. Does anyone have an idea?
When I run the following code on my Word Document:
Public Sub setTextColumns(ByRef LeDoc As Document)
Dim c As Long
Dim x As Range
For c = 2 To LeDoc.InlineShapes.Count - 1
Set x = LeDoc.Range( _
LeDoc.InlineShapes(c).Range.End + 1, _
LeDoc.InlineShapes(c + 1).Range.Start)
LeDoc.Range(Start:=LeDoc.InlineShapes(c).Range.End+1, _
End:=LeDoc.InlineShapes(c).Range.End). _
InsertBreak Type:=wdSectionBreakContinuous
LeDoc.Range(Start:=LeDoc.InlineShapes(c + 1).Range.Start, _
End:=LeDoc.InlineShapes(c + 1).Range.Start). _
InsertBreak Type:=wdSectionBreakContinuous
x.PageSetup.TextColumns.SetCount 3
Next c
I get, about 30 loops through, message saying "Not enough memory. When this action will finish, it will be impossible to undo. Continue?", to which I answer yes.
The problem is, at this point, my code stops running, and Word shuts down without further warning. I tried to check out exactly how many lines of code after the message prompt this happenned, but by adding Message Boxes to find out, the warning stopped appearing and Word didn'T crash.
Now, I know my problem is kind of fixed, but I'm jsut really confused as to WHY this happens. Does anyone have an idea?