OUT OF STACK SPACE error at GetObject line

adds416

New Member
Joined
Jun 14, 2010
Messages
10
Hi,
I wrote a 10 line program to import a word table to excel, as shown below.
Code:
Sub Method1()
 
Debug.Print Application.MemoryTotal & " available; " & _
            Application.MemoryFree & " free; " & _
            Application.MemoryUsed & " used"
Dim wordTable As Object
Set wordTable = GetObject(ThisWorkbook.Path & "\test.doc")    '<-- error here
With wordTable
    .tables(1).Range.Copy
End With
Sheets(1).Paste 
Set wordTable = Nothing
End Sub

The problem is that i get "Error 28: Out of stack space" whenever I run it, despite below actions
-I dont have any events for any even cascade
-NO fixed-length strings
-NO other procedures in the project
-NO procedure calls in this procedure
-NO other variable except WordTable as Object, which i destroy when i am done with it
-NO nested loops or DoEvents
-NO public declared variables
-NOTHING else open when i run this program

Please help! I am running out of options and I would really like to get this working. Is there a way to track stack space or clear it?
Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I don't know why you are getting that error. Try this alternative code

Code:
Sub ImportWordTable1()
'Import one table to current sheet
Dim wdDoc As Object
Dim wdFileName As Variant
Dim TableNo As Integer 'table number in Word
Dim iRow As Long 'row index in Excel
Dim iCol As Integer 'column index in Excel
wdFileName = Application.GetOpenFilename("Word files (*.doc),*.doc", , _
"Browse for file containing table to be imported")
If wdFileName = False Then Exit Sub '(user cancelled import file browser)
Set wdDoc = GetObject(wdFileName) 'open Word file
With wdDoc
    TableNo = wdDoc.tables.Count
    If TableNo = 0 Then
        MsgBox "This document contains no tables", _
            vbExclamation, "Import Word Table"
    ElseIf TableNo > 1 Then
    TableNo = InputBox("This Word document contains " & TableNo & " tables." & vbCrLf & _
        "Enter table number of table to import", "Import Word Table", "1")
    End If
    With .tables(TableNo)
'copy cell contents from Word table cells to Excel cells
        For iRow = 1 To .Rows.Count
            For iCol = 1 To .Columns.Count
                On Error Resume Next
                Cells(iRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
                On Error GoTo 0
            Next iCol
        Next iRow
    End With
End With
Set wdDoc = Nothing
End Sub
 
Upvote 0
Thanks for the suggestion, but I have already used that code b4 and gave same error.
Nevertheless, I tried it again and crossed my fingers, but fate isnt on my side on this one. Still gives the error on line
Code:
Set wdDoc = GetObject(wdFileName) 'open Word file, error at GetObject
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top