2009-12-23 586 views
4

當我設置Excel apllications displayalert propery爲true時,此異常被解僱... 爲什麼?異常來自HRESULT:0x800AC472

+0

你能給了數據?關於例外?你的代碼? etc ... – 2009-12-23 13:25:25

+0

@Tony objExcelAppDataSheet.DisplayAlerts = True 只是行,我得到異常 objExcelAppDataSheet是Excel工作表的名稱。 – Kiran 2009-12-23 13:47:50

回答

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自己,所以錯誤的道歉。

+0

我以前讀過,但我沒有得到什麼? – Kiran 2009-12-23 13:29:37

+0

一個建議是將你的調用放在一個循環內的try塊內,並且繼續嘗試調用直到成功。 – richj 2009-12-23 13:40:50

+0

@richj 其工作正常 Thnx! – Kiran 2009-12-23 14:00:18

0

的vb.net代碼,循環和重試,直到range.value被接受的System.Array

  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,.NET代碼爲richj答案

+0

請添加您的答案的解釋。 – drum 2017-06-29 04:22:00

相關問題