title image


Smiley Re: Das OK einer Message Box per Quellcode auslösen?
Hi,



das geht recht einfach mit der MsgBox des WSH:



Function MsgBox_mit_Zeitlimit(text As String, button As Integer, icon As Integer, Optional time2wait As Integer, Optional titel As String) As Integer

    'Verweis auf WSH Object Model setzen

    'Syntax: WshShell.Popup strMessage [,intSecondsToWait] [,strTitle] [,intType]

    

    'ButtonTypen:

    '0 = OK

    '1 = OK , Cancel

    '2 = Abort , Ignore, Retry

    '3 = Yes , No, Cancel

    '4 = Yes , No

    '5 = Retry , Cancel

    

    'IconTypen:

    '16 = Critical

    '32 = Question

    '48 = Exclamation

    '64 = Information

    

    'RückgabeWerte:

    '1 = OK

    '2 = Cancel

    '3 = Abort

    '4 = Retry

    '5 = Ignore

    '6 = Yes

    '7 = No

    '-1 = None, message box was dismissed automatically (timeout)

    

    Dim WshShell

    Dim intBack As Integer

    Set WshShell = CreateObject("WScript.Shell")

    

    MsgBox_mit_Zeitlimit = (intBack = WshShell.Popup(text, time2wait, titel, button + icon))

End Function



Sub Beispiel()

    ret = MsgBox_mit_Zeitlimit("Möchten Sie jetzt speichern?", 4, 32, 1, "Speicherabfrage")

    Select Case ret

        Case 6

            Application.DisplayAlerts = False

            'ActiveWorkbook.Save

            Application.DisplayAlerts = True

        Case 7

            '...

        Case -1, 0

            MsgBox "User hat nichts gedrückt", vbCritical, "Ohje Ohje"

            '...z.b. das ganze in 10min wieder starten

    End Select

End Sub

Code created by Spotlighthelper 0.02


Der Zugvogel
(mIsCHa Reichelt)


geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: