" Excel VBA运行时错误' 424'需要的对象"不停地弹出

时间:2017-07-17 06:11:39

标签: excel vba excel-vba

嗨,我是VBA的新手,我不断在电子表格上每隔一段时间弹出一次错误信息。我怎么知道造成这种情况的原因?

以下是对我的代码的引用:

Private Sub Worksheet_Calculate()
Dim OutApp As Object
Dim OutMail As Object
Dim Target As Double
Dim bRun As Boolean
Dim iHour As Integer

'On Error GoTo debugtest

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

Target = ThisWorkbook.Sheets("Quotes").Range("Q1")

'Reset the trigger flag if the last triggered time was yesterday or earlier
If Day(Now()) <> Day(ThisWorkbook.Sheets("Quotes").Range("Q3")) Then
    'Sheets("Quotes").Range("Q2") = False
End If

bRun = False
iHour = Application.WorksheetFunction.Text(Time(), "[hh]")
If iHour >= ThisWorkbook.Sheets("Quotes").Range("Q9") Or iHour <= ThisWorkbook.Sheets("Quotes").Range("Q10") Then
    bRun = True
End If

我该怎么办?

0 个答案:

没有答案