COMException(0x80010108 - RPC_E_DISCONNECTED)关闭Excel.Workbook时 [英] COMException (0x80010108 - RPC_E_DISCONNECTED) When Closing Excel.Workbook

查看:751
本文介绍了COMException(0x80010108 - RPC_E_DISCONNECTED)关闭Excel.Workbook时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行以下代码时,我会收到以下异常:

When I run the following code, I get the exception below:

''# NOTE: ExcelApp is a Private main form variable
Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks
Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename)
Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report")

''# Retreive data from sheet

ReleaseCOM(ReportSheet)
ReportBook.Close(True) ''# Error raised here
ReleaseCOM(ReportBook)
ReleaseCOM(ReportBooks)




ERROR:
COMException was unhandled
The object invoked has disconnected from its clients.
(Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))


请帮助我诊断并克服这个错误。

Please help me diagnose and overcome this error.

推荐答案

RPC_DISCONNECTED ...可怕的被调用的对象与客户端断开连接问题。有很多原因,看起来你已经用 Excel覆盖了全局变量问题。。你可以把第一个 ReleaseCOM(ReportSheet) ReportBook(关闭)下运行吗?另外,请查看

RPC_DISCONNECTED...the dreaded "The object invoked has disconnected from its clients." issue. There are a ton of causes to this, looks like you've covered the global variables issue with Excel.. Can you put the first ReleaseCOM(ReportSheet) below ReportBook(Close) and run it? Also, check out this.

这篇关于COMException(0x80010108 - RPC_E_DISCONNECTED)关闭Excel.Workbook时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆