Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
The following example demonstrates how to undo or redo text editing within a TextBox or within the text area of a ComboBox. This sample checks whether an undo or redo operation can occur and then performs the appropriate action. Im Beipiel werden die CanUndo - und die CanRedo -Eigenschaften sowie die UndoAction - und die RedoAction -Methoden verwendet.
To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:
A TextBox named TextBox1.
A ComboBox named ComboBox1.
Zwei Befehlsschaltflächen-Steuerelemente ( CommandButton ) mit der Bezeichnung "CommandButton1" und "CommandButton2".
Dim UserForm1
Sub CommandButton1_Click()
If UserForm1.CanUndo = True Then
UserForm1.UndoAction
MsgBox "Undid IT"
Else
MsgBox "No undo performed."
End If
End Sub
Sub CommandButton2_Click()
If UserForm1.CanRedo = True Then
UserForm1.RedoAction
MsgBox "Redid IT"
Else
MsgBox "No redo performed."
End If
End Sub
Sub Item_Open()
Set UserForm1 = Item.GetInspector.ModifiedFormPages("P.2")
Set TextBox1 = UserForm1.Controls("TextBox1")
Set ComboBox1 = UserForm1.Controls("ComboBox1")
Set CommandButton1 = UserForm1.Controls("CommandButton1")
Set CommandButton2 = UserForm1.Controls("CommandButton2")
TextBox1.Text = "Type your text here."
ComboBox1.ColumnCount = 3
ComboBox1.AddItem "Choice 1, column 1"
ComboBox1.List(0, 1) = "Choice 1, column 2"
ComboBox1.List(0, 2) = "Choice 1, column 3"
CommandButton1.Caption = "Undo"
CommandButton2.Caption = "Redo"
End Sub
Support und Feedback
Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.