Document.Redo メソッド (Publisher)

Redoes the last action or a specified number of actions. [標準] ツール バーの [やり直し] ボタンの横にある矢印を選択したときに表示される項目の一覧に対応します。 このメソッドを呼び出すと、 Undo メソッドが反転します。

構文

やり直し (カウント)

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

パラメーター

名前 必須 / オプション データ型 説明
Count 省略可能 長整数型 (Long) やり直す操作の数を指定します。 既定値は 1 で、省略した場合、最後の操作だけがやり直されます。

戻り値

なし

解説

再実行スタックに対するアクションがない場合、または Count がスタック上に存在するアクションの数を超えたときに呼び出された場合、 Redo メソッドは可能な限り多くのアクションをやり直し、残りのアクションを無視します。

1 回の Redo の呼び出しで、最大 20 までの操作をやり直すことができます。

次の例では、 Redo メソッドを使用して、Undo メソッドを使用して元に戻されたアクションのサブセットを やり直 します。

パート 1 では、作業中の文書の 4 ページ目にテキスト フレームを含む四角形を作成します。 さまざまなフォント プロパティが設定され、テキストがテキスト フレームに追加されます。 この場合、"このフォントは Courier" というテキストが 12 ポイント太字の Courier フォントに設定されます。

第 2 部では、テキスト フレーム内のテキストが Verdana フォントであるかどうかをテストします。 元に戻さない場合は、 Undo メソッドを使用して、元に戻すスタックの最後の 4 つのアクションを元に戻します。 次に、やり直しメソッドを使用して、元に戻した最後の 4 つのアクションのうち最初の 2 つをやり直します。 この例では、3 番目の操作 (フォント サイズの設定) と 4 番目の操作 (太字フォントの設定) がやり直されます。 Verdana にフォント名が変更し、テキストを変更します。

Dim thePage As page 
Dim theShape As Shape 
Dim theDoc As Publisher.Document 
 
Set theDoc = ActiveDocument 
Set thePage = theDoc.Pages(4) 
 
' Part 1 
With theDoc 
 With thePage 
 ' Setting the shape creates the first action 
 Set theShape = .Shapes.AddShape(msoShapeRectangle, _ 
 75, 75, 190, 30) 
 ' Setting the text range creates the second action 
 With theShape.TextFrame.TextRange 
 ' Setting the font size creates the third action 
 .Font.Size = 12 
 ' Setting the font to bold creates the fourth action 
 .Font.Bold = msoTrue 
 ' Setting the font name creates the fifth action 
 .Font.Name = "Courier" 
 ' Setting the text creates the sixth action 
 .Text = "This font is Courier." 
 End With 
 End With 
 
 ' Part 2 
 If Not thePage.Shapes(1).TextFrame.TextRange.Font.Name = "Verdana" Then 
 .Undo (4) 
 With thePage 
 With theShape.TextFrame.TextRange 
 ' Redo redoes the first two of the four actions that were just undone 
 theDoc.Redo (2) 
 .Font.Name = "Verdana" 
 .Text = "This font is Verdana." 
 End With 
 End With 
 End If 
End With

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

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