无法在excel vba中关闭幽灵项目

问题描述

我使用Excel 2003从股票市场(500支以上的股票,每个股票有12个数据点)获取实时数据。主应用程序(18,00行代码)还计算了趋势,并预测(尝试)以指示最佳交易。

每天需要3次下载其他信息,并将其导出到数据库(开盘价,价差和收盘价)

我通过在同一实例中打开辅助Excel文件 来做到这一点(在单独的实例中打开每个月要多花我$ 250)。

问题在于,尽管辅助工作簿已关闭,但“ ghost”项目仍保留在主应用程序中。结果,我收到“内存不足”错误。由于我对OpenPrice和ClosingValues使用相同的辅助对象,因此实际上我得到了两个“ ghost”项目,都命名为“ DailyValues”

我尝试从其内部关闭辅助工作簿:

此工作簿。关闭

,并通过调用应用程序:

DoEvents
If IsWorkbookOpen(pstrFileName) = False Then
  Workbooks.Open (pstrFilePath & pstrFileName)
End If
Call ReadText("Saving Spread")
'Application.Run (pstrFileName & "!ExportSpreadAndClose")
Application.Run (pstrFileName & "!UpdateAndExport")
strExportTime = "Spread Exported at " & Format(Now(),"HH:mm")
lngSpreadCount = Workbooks(pstrFileName).Worksheets("SettingsSP").Range("SpreadCount").Value
If lngSpreadCount > 0 Then
 Call ReadText(Format(lngSpreadCount,"#,##0") & strExportTime)
 Debug.Print Format(lngSpreadCount,##0") & strExportTime
Else
 Call ReadText("Error Exporting Spread")
 Debug.Print "Error Exporting Spread"
End If

If pbolCloseSpread = True Then
 If IsWorkbookOpen(pstrFileName) = True Then
    Workbooks(pstrFileName).Saved = True
    Workbooks(pstrFileName).Close
  End If
End If

没人帮忙。

没有共享的全局变量,但是我确实从主应用程序的辅助应用程序中读取了export的返回值。

是否可以将其连接到数据库导出?主应用程序每分钟一次将数据导出到数据库(500行以上,12列以上),没有不良影响。

在Excel 2010中,我没有出现内存错误,但是“ ghost”项目仍然存在。在同一台计算机(i7、6核,48Gb内存,Server 2008 R2)上,Excel 2010的速度几乎是2003年的两倍。

请告知

P.S。自1992年以来,我一直在使用Excel。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)