Message box

Confirmation Message box

 Sub MsgboxConfirmation()
    Dim ans As VbMsgBoxResult
    ans = MsgBox("Are you Sure want to close this file?", vbYesNo, "Confirm Closing?")
        
    If ans = vbNo Then
        MsgBox "You Clicked No"
    ElseIf ans = vbYes Then
        MsgBox "You Clicked Yes"
    End If
End Sub


Read File from Text file to Message box

Sub Check()

    Const szFileName As String = "ReadMe.txt"
    Dim szThisPath As String
        szThisPath = ThisWorkbook.Path
    Dim szPathSep As String
        szPathSep = Application.PathSeparator
    Dim szValidPath As String
        szValidPath = szThisPath & szPathSep & szFileName
    On Error GoTo ErrHandler
    Dim lFile As Long
    Dim szLine As String
    lFile = FreeFile()
    Open szValidPath For Input As lFile
        While Not EOF(lFile)
            Line Input #lFile, szLine
            'MsgBox szLine
            'If szLine = "Ajeet" Then
            '    MsgBox szLine
            'End If
            
        Wend
    Close lFile
    Exit Sub
ErrHandler:
    MsgBox Err.Description
End Sub


AutoClose Message Box in VBA

Public Sub Msgout()
    Const iSec As Long = 5
    Const msg As String = "This message closes automatically after 5 seconds !"
    Dim iTitle As String
    iTitle = "ExcelMacroClasses.com"
    CreateObject("WScript.Shell").Popup msg, iSec, iTitle
End Sub
Total Page Visits: 615 - Today Page Visits: 7