Word VBA macro causes 0x80030008 error

R

RomanP

I am trying to create in Word document several tables with "Forms.TextBox.1"
controls in each cell. The dimension of each table is 10 columns x 75 rows.
After the creation of 3-rd table Word can not save file and return error
0x80030008 - There is insufficient memory available to complete operation.".
What memory is insufficient? How to solve this problem?

Word 2003 (11.5604.8172).
Code of macro is following:
---------------------------------------------------------------------
Sub InsertTable(rowsNum, columnsNum, controlClassType)

Set myRange = ActiveDocument.ActiveWindow.Selection.Range
Set myTable = myRange.Tables.Add(Range:=myRange, NumRows:=1,
NumColumns:=10)

Set myRows = myTable.rows

For I = 1 To rowsNum

Set myRow = myRows.Add
Set myCells = myRow.Cells

For J = 1 To columnsNum
Set myCell = myCells(J)
Set myRange = myCell.Range
Set myShapes = myRange.InlineShapes
Set myShape = myShapes.AddOLEControl(classType:=controlClassType)
If (controlClassType = "Forms.TextBox.1") Then
myShape.OLEFormat.Object.AutoSize = True ' use only
Else
myShape.OLEFormat.Activate
End If
Next J
ActiveDocument.UndoClear

Next I

End Sub

Sub AppendParagraph()
Set rng = ActiveDocument.Range
rng.Collapse Direction:=wdCollapseEnd
rng.Select
Selection.Range.InsertParagraphAfter
End Sub

Sub TestTablesSave()
myClassType = "Forms.TextBox.1"

InsertTable 75, 10, myClassType
AppendParagraph
ActiveDocument.Save

InsertTable 75, 10, myClassType
AppendParagraph
ActiveDocument.Save

InsertTable 75, 10, myClassType
AppendParagraph
ActiveDocument.Save
End Sub
 
R

Roman Prytkov

Resend from another account - I hope to receive answer as it was promised to
MSDN subscriber.
--------------------
I am trying to create in Word document several tables with "Forms.TextBox.1"
controls in each cell. The dimension of each table is 10 columns x 75 rows.
After the creation of 3-rd table Word can not save file and return error
0x80030008 - There is insufficient memory available to complete operation.".
What memory is insufficient? How to solve this problem?

Word 2003 (11.5604.8172).
Code of macro is following:
---------------------------------------------------------------------
Sub InsertTable(rowsNum, columnsNum, controlClassType)

Set myRange = ActiveDocument.ActiveWindow.Selection.Range
Set myTable = myRange.Tables.Add(Range:=myRange, NumRows:=1,
NumColumns:=10)

Set myRows = myTable.rows

For I = 1 To rowsNum

Set myRow = myRows.Add
Set myCells = myRow.Cells

For J = 1 To columnsNum
Set myCell = myCells(J)
Set myRange = myCell.Range
Set myShapes = myRange.InlineShapes
Set myShape = myShapes.AddOLEControl(classType:=controlClassType)
If (controlClassType = "Forms.TextBox.1") Then
myShape.OLEFormat.Object.AutoSize = True ' use only
Else
myShape.OLEFormat.Activate
End If
Next J
ActiveDocument.UndoClear

Next I

End Sub

Sub AppendParagraph()
Set rng = ActiveDocument.Range
rng.Collapse Direction:=wdCollapseEnd
rng.Select
Selection.Range.InsertParagraphAfter
End Sub

Sub TestTablesSave()
myClassType = "Forms.TextBox.1"

InsertTable 75, 10, myClassType
AppendParagraph
ActiveDocument.Save

InsertTable 75, 10, myClassType
AppendParagraph
ActiveDocument.Save

InsertTable 75, 10, myClassType
AppendParagraph
ActiveDocument.Save
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top