gpt4 book ai didi

excel - 运行时错误 '7' : Out of memory

转载 作者:行者123 更新时间:2023-12-02 17:04:18 24 4
gpt4 key购买 nike

我正在尝试编辑 Word 文档中的嵌入图表。我的源代码如下。已经用了很长时间了,但最近两天没用。我收到此错误:

Run-time error '7': Out of memory

查了很多资料,还是没明白问题所在。当我关闭计算机并打开它后,它可以正常工作,但是当我再次出现错误时。

这部分出现错误:

       '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)
<小时/>
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 & 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 ----> | XY1 | XY2 | XY2 | ....
' After Set Value | 0,33| 0,1 | 0,46| ....
oRange.Cells(1, i + 1) = ChartTitle & (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

最佳答案

我以前也遇到过这种情况。我有相同的解决方案,退出 Excel,释放一些内存,然后重试 - 它起作用了。使用此功能时您可能必须关闭其他程序。正如它所说的那样,缺乏可用内存。

请记住,如果您运行了其他将信息复制到剪贴板的宏,则用于运行该宏的可用 RAM 将会减少。

此外,您使用的是 32 位还是 64 位 Excel - 64 位将允许您使用更多 RAM。

关于excel - 运行时错误 '7' : Out of memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18277514/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com