title: Run-time error '7': Out of memory
body: <p>I'm trying to edit embedded charts in Word documents. My source code is below. It has worked a long time but not for the last two days. I get this error:</p>
  
  <blockquote>
    <p>Run-time error '7':   Out of memory</p>
  </blockquote>
  
  <p>I have searched a lot , but I don't understand the problem. When I shutdown computer and after open it, then it works correctly, but after I get error again.</p>
  
  <p>It gives error in this part:</p>
  
  <pre><code>       'create range with Cell
          Set oChart = oInShapes.Chart
          oChart.ChartData.Activate  ' ***Note: It gives error here***
          'Set oWorkbook = oChart.ChartData.Workbook
          Set oWorksheet = oChart.ChartData.Workbook.Worksheets("Tabelle1")
          Set oRange = oWorksheet.Range(Cell)
  </code></pre>
  
  <hr>
  
  <pre><code>Public Sub updatechart(Doc As word.Application, ChartName As String, ChartTitle As String, Cell As String, data As String)`
  
          Dim oInShapes As word.InlineShape
          Dim oChart As word.Chart
          Dim oWorksheet As Excel.Worksheet
          'Dim oWorkbook As Excel.Workbook
  
          Dim columnArray() As String
          Dim rowArray() As String
          Dim oRange As Range
          Dim i As Integer
          Dim j As Integer
  
          For Each oInShapes In Doc.ActiveDocument.InlineShapes
          ' Check Shape type and Chart Title
              If oInShapes.HasChart Then
                  'create range with Cell
                  Set oChart = oInShapes.Chart
                  oChart.ChartData.Activate  ' ***Note: It gives error here***
                  'Set oWorkbook = oChart.ChartData.Workbook
                  Set oWorksheet = oChart.ChartData.Workbook.Worksheets("Tabelle1")
                  Set oRange = oWorksheet.Range(Cell)
                  ' Commet for debug
                  'oWorksheet.Range("B33") = (ChartTitle &amp; 33)
  
                  ' Split text
                  columnArray = Split(data, SeperateChar)
                  For i = LBound(columnArray) To UBound(columnArray)
                      rowArray = Split(Trim(columnArray(i)), " ")
                      ' Set Title. For example; ChartTitle = "XY" ----- Table Titles ----&gt;  | XY1 | XY2 | XY2 | ....
                      ' After Set Value                                                     | 0,33| 0,1 | 0,46| ....
                      oRange.Cells(1, i + 1) = ChartTitle &amp; (i + 1)
                      For j = LBound(rowArray) To UBound(rowArray)
                          ' Set Values
                          oRange.Cells(j + 2, i + 1) = CDbl(rowArray(j))
                      Next j
                  Next i
  
                  'oWorkbook.Close
                  oChart.Refresh
              End If
          Next
  
          Set oInShapes = Nothing
          Set oChart = Nothing
          Set oWorksheet = Nothing
          'Set oWorkbook = Nothing
          Erase rowArray, columnArray
      End Sub
  </code></pre>