Document.EndCustomUndoAction メソッド (Publisher)

元に戻す操作 1 回分を作成するために一連の操作をまとめる終点を指定します。 BeginCustomUndoAction メソッドは、単一の元に戻すアクションの作成に使用されるアクションの開始点とラベル (テキストの説明) を指定するために使用されます。 まとめられた一連の操作は、元に戻す操作を 1 回実行することで元に戻すことができます。

構文

EndCustomUndoAction

Document オブジェクトを表す変数。

注釈

BeginCustomUndoAction メソッドは、 EndCustomUndoAction メソッドが呼び出される前に呼び出す必要があります。 EndCustomUndoActionBeginCustomUndoAction する前に呼び出された場合は、実行時エラーが返されます。

次の例には、2 つのユーザー設定の元に戻す操作が含まれています。 1 つ目は、作業中の文書の 4 ページ目に作成されます。 BeginCustomUndoAction メソッドを使用して、ユーザー設定の [元に戻す操作を開始するポイントを指定します。 6 つの個別の操作が行われ、 EndCustomUndoAction の呼び出しで 1 つのアクションにラップされるし。

最初のユーザー設定の元に戻す操作内で作成されたテキスト ボックス内にあるテキストのフォントが、MS P ゴシックであるかどうかが判断されます。 フォントが MS P ゴシックでない場合は、 UndoActionsAvailable をパラメーターとして Undo メソッドが呼び出されます。 この場合、元に戻す操作で実行されるものは 1 つだけです。 したがって、 Undo メソッドを呼び出すと、1 つの操作だけが元に戻されますが、この 1 つの元に戻す操作には、6 つの操作が含まれます。

次に、2 つ目の元に戻す操作が作成されます。この操作は、後ほど元に戻す操作 1 回によって元に戻すことができます。

この使用例は、作業中の文書にページが少なくとも 4 ページ含まれていることを前提にしています。

Dim thePage As page 
Dim theShape As Shape 
Dim theDoc As Publisher.Document 
 
Set theDoc = ActiveDocument 
Set thePage = theDoc.Pages(4) 
 
With theDoc 
 ' The following six of actions are wrapped to create one 
 ' custom undo action named "Add Rectangle and Courier Text". 
 .BeginCustomUndoAction ("Add Rectangle and Courier Text") 
 With thePage 
 Set theShape = .Shapes.AddShape(msoShapeRectangle, _ 
 75, 75, 190, 30) 
 With theShape.TextFrame.TextRange 
 .Font.Size = 14 
 .Font.Bold = msoTrue 
 .Font.Name = "Courier" 
 .Text = "This font is Courier." 
 End With 
 End With 
 .EndCustomUndoAction 
 
 If Not thePage.Shapes(1).TextFrame.TextRange.Font.Name = "Verdana" Then 
 ' This call to Undo will undo all actions that are available. 
 ' In this case, there is only one action that can be undone. 
 .Undo (.UndoActionsAvailable) 
 ' A new custom undo action is created with a name of 
 ' "Add Balloon and Verdana Text". 
 .BeginCustomUndoAction ("Add Balloon and Verdana Text") 
 With thePage 
 Set theShape = .Shapes.AddShape(msoShapeBalloon, _ 
 75, 75, 190, 30) 
 With theShape.TextFrame.TextRange 
 .Font.Size = 11 
 .Font.Name = "Verdana" 
 .Text = "This font is Verdana." 
 End With 
 End With 
 .EndCustomUndoAction 
 End If 
End With

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。