来自HRESULT的异常:0x800AC472

时间:2009-12-23 13:18:33

标签: vb.net

当我将Excel应用程序displayalerts属性设置为true时,会触发此异常... 为什么呢?

2 个答案:

答案 0 :(得分:4)

属性浏览器是否已暂停?如果是这样,这可能会有所帮助:HRESULT 800ac472 from set operations in Excel


一个建议是将您的调用放在循环内的try块中,并继续尝试调用直到成功。它可能看起来像这样:

retry = True

Do
    Try
        'Put your call here.
        retry = False
    Catch ex As Exception
        'Need to try again,
        'If this isn't the 0x800ac472 exception it should be re-thrown,
        'Use Sleep(50) to reduce the number of retries,
        'Use Exit Do or re-throw the exception to give up.
    End Try
While retry

我自己不用VB写,所以对任何错误道歉。

答案 1 :(得分:1)

vb.net代码,循环并重试,直到system.array接受range.value

            Dim xlApp As Excel.Application = New Excel.Application
            Dim wb As Excel.Workbook = xlApp.Workbooks.Open(paths)
            Dim ws As Excel.Worksheet=wb.Worksheets(1)
            Dim range As Excel.Range = Nothing               
            range = ws.UsedRange
            Dim wh As System.Array
            Dim retryRange As Boolean = False
            While retryRange
                Try
                    wh = range.Value(Excel.XlRangeValueDataType.xlRangeValueDefault)
                    retryRange = False
                Catch ex As Exception
                    retryRange = True
                End Try
            End While

vb,richj回答的网络代码