Document.BeginCustomUndoAction メソッド (Publisher)

元に戻す操作の 1 回分を作成するために、一連の操作をまとめる始点とラベル (操作内容を表すテキスト) を指定します。

これらの一連の操作の終点を指定するには、 EndCustomUndoAction メソッドを使用します。 まとめられた一連の操作は、元に戻す操作を 1 回実行することで元に戻すことができます。

構文

BeginCustomUndoAction (ActionName)

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

パラメーター

名前 必須 / オプション データ型 説明
ActionName 必須 String 元に戻す操作 1 回に対応するラベルを指定します。 このラベルは、[標準] ツール バーの [元に戻す] ボタンの横にある矢印を選択すると表示されます。

注釈

次の ドキュメント オブジェクトのメソッドは、カスタムの [元に戻す操作内でご利用いただけません。 カスタムの元に戻す操作内でこれらのメソッドと呼ばれます場合は、実行時エラーが返されます。

  • Close
  • MailMerge.DataSource.Close
  • PrintOut
  • Redo
  • Save
  • SaveAs
  • Undo
  • UndoClear
  • UpdateOLEObjects

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

別のカスタム元に戻す操作内でカスタムの元に戻す操作を入れ子にすることはできますが、入れ子になったカスタム元に戻す操作は効果がありません。 最も外側のカスタム元に戻す操作のみがアクティブです。

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

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

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

Dim thePage As page 
Dim theShape As Shape 
Dim theDoc As Publisher.Document 
 
Set theDoc = ActiveDocument 
Set thePage = theDoc.Pages(1) 
 
With theDoc 
 ' The following six 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 のサポートおよびフィードバックを参照してください。