在我設定的工作表SelectionChange事件:Application.Interactive =真失敗
Application.Interactive = False
.... do work
Application.Interactive = True
出於某種原因互動是沒有得到重新設置爲true,即使我知道正在執行的代碼。
Excel 2013
任何想法?
在我設定的工作表SelectionChange事件:Application.Interactive =真失敗
Application.Interactive = False
.... do work
Application.Interactive = True
出於某種原因互動是沒有得到重新設置爲true,即使我知道正在執行的代碼。
Excel 2013
任何想法?
Sub Main()
Debug.Print Application.Interactive
Application.Interactive = False
Debug.Print Application.Interactive
Application.Interactive = True
Debug.Print Application.Interactive
End Sub
不會失敗,我...嘗試這一點,see more here
既然你已經發現的原因未能得出結論可能是因爲Application.Volatile
需要被設置爲false的函數因爲Interactive
模式會阻止用戶界面,並且Volatile
會根據用戶輸入計算內容。在用戶輸入被阻止的情況下,您不能期望評估用戶輸入的函數能夠正常工作。一個排除另一個 - 希望是有道理的。
此外,檢查您的on error resume next
或on error goto <label>
語句作爲會導致跳過一些代碼因此Application.Interactive = True
就永遠不會得到執行的。
感謝您的答覆 - 但看到上面的評論。與Application.Volatile有關的事情 –
這原來是一個紅鯡魚。我發現我有一個設置ON ERROR RESUME NEXT的過程,並且在嚴重錯誤之後,代碼在調用過程(Application.Interactive = True)中跨越語句而不報告更多錯誤。換句話說,Application.Interactive = True是因爲先前的錯誤而引發錯誤,但我沒有看到錯誤消息,並且看起來該語句不起作用。 –
@brigzy偉大我很高興你解決了這個問題。我會更新答案以反映這一點 – 2013-11-01 16:26:04
啊等等......我發現只有在Autofilter打開的情況下才是問題。 (同樣的行爲2010年的方式) –
越來越近 - 我有一個標記爲'Application.Volatile'的功能,如果我註釋掉這一行 - 它工作正常。該函數用於列標題單元格中顯示有效的自動濾波器公式。 –
紅鯡魚 - 見答案評論 –