property HTML.CanUndo as Boolean
Determines whether the last html operation can be undone.

TypeDescription
Boolean A boolean expression that indicates whether the last html operation can be undone.

You can use the CanUndo property just before doing an undo operation by code. Also, the CanUndo property can be used to update your menu, button. The CanRedo property determines if the redo queue contains any actions. Use the AllowUndoRedo property to enable undo/redo support.

The following VB sample shows how you can implement the Undo command, when user presses the CTRL + J key:

Private Const WM_COMMAND = &H111
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Sub HTML1_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyJ) And (Shift = 2) Then
        With HTML1
            If .CanUndo Then
                SendMessage .hwnd, WM_COMMAND, &HE12B * 65536, 0
            End If
        End With
    End If
End Sub