VBA/Excel/Access/Word/Application/Application Events — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:46, 26 мая 2010

Using the AdvancedSearchComplete Event and the AdvancedSearchStopped Event

 
Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
    MsgBox "The search has finished running and found " & _
        SearchObject.Results.Count & " results.", vbOKOnly + vbInformation, _
        "Advanced Search Complete Event"
End Sub



Using the ItemSend Event

 
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Subject = "" Then
        MsgBox "Please add a subject line to this message."
        Cancel = True
    End If
End Sub



Using the Quit Event

 
Sub Application_Quit()
    Dim strMessage As String
    Select Case Format(Date, "MM/DD/YYYY")
        Case "01/13/2006"
            strMessage = "Next Monday is Martin Luther King Day."
        Case "02/17/2006"
            strMessage = "Next Monday is Presidents Day."
        Case "05/26/2006"
            strMessage = "Next Monday is Memorial Day."
        Case "06/30/2006"
            strMessage = "Next Tuesday is Independence Day." & _
                " Monday is a company holiday."
        Case "09/01/2006"
            strMessage = "Next Monday is Labor Day."
        "other National Holidays here
        End Select
        MsgBox strMessage, vbOKCancel + vbExclamation, "Don"t Forget..."
End Sub



Using the Startup Event

 
Sub Application_Startup()
    Dim myNoteItem As NoteItem
    Set myNoteItem = Application.CreateItem(ItemType:=olNoteItem)
    myNoteItem.Body = "Please start a new time card for the day."
    myNoteItem.Display
End Sub