0

Word 2010を使用して、プログラミングプロジェクトのテスト計画のテンプレートを作成しようとしています。やりたいことを示すモックアップテンプレートを作成しました。

プロジェクトテスト計画のモックアップ

私がやりたいのは、Wordリボンの何かをクリックして、テンプレートに次のテストテーブルを生成させ、キャプションをシーケンス処理できるようにすることです。テーブルが生成されたら、テスト用のテーブルフィールドに入力します。

このテンプレートを作成できるように、Wordヘルプまたは他の場所で何を検索するかを誰かに教えてもらえますか?

4

2 に答える 2

1

私は個人的にこのためのマクロを作成します。または、コードを使用してテンプレートに埋め込み、メニュー項目を追加して次のようなものを追加することもできます。(非常に大まかな方法​​ですが、レイアウトと数値の昇順でテーブルを生成するために使用できます)、前のテストが中断した場所を知るほど動的ではありませんが、開始点にする必要があります。)

Dim iCount As Integer

iCount = CInt(InputBox("How many tables?", "Table Count", 1))

For icurtable = 1 To iCount

    Dim oTableRange As Paragraph
    Dim oTable As Table
    Dim oCaption As Paragraph

    Set oCaption = ActiveDocument.Paragraphs.Add

    Call oCaption.Range.InsertBefore(CStr(icurtable))

    Set oTableRange = ActiveDocument.Paragraphs.Add

    Set oTable = oTableRange.Range.Tables.Add(oTableRange.Range, 4, 1, True, True)

    oTable.Rows.First.Cells(1).Range.InsertBefore ("Setup:")
    oTable.Rows(2).Cells(1).Range.InsertBefore ("Test:")
    oTable.Rows(3).Cells(1).Range.InsertBefore ("Expected Response:")
    oTable.Rows(4).Cells(1).Range.InsertBefore ("Restore")

    Call oTableRange.Range.InsertAfter(vbCrLf)

Next
于 2012-03-30T16:36:05.913 に答える
0

他の誰かがこの質問に出くわした場合に備えて、私は私の解決策を提供します。テーブルの中にテーブルを作成して、テストケース番号が左側に表示されるようにすることにしました。

Sachaの答えをモデルとして使用し、マクロレコーダーを自由に使用して、私が望むことのほとんどを実行するこのVBAマクロを思いつきました。

Sub InsertTestTable()

'
' InsertTestTable Macro
' This macro inserts a test table into the document.
'

Dim oTable As Table
Dim iTable As Table

Set oTable = ActiveDocument.Tables.Add(Selection.Range, 1, 2, _
    wdWord9TableBehavior, wdAutoFitContent)

Selection.TypeText ("1.")
Selection.MoveRight

Set iTable = ActiveDocument.Tables.Add(Selection.Range, 4, 2, _
    wdWord9TableBehavior, wdAutoFitContent)

iTable.Rows(1).Cells(1).Range.InsertBefore ("Setup:")
iTable.Rows(2).Cells(1).Range.InsertBefore ("Test:")
iTable.Rows(3).Cells(1).Range.InsertBefore ("Expected Response:")
iTable.Rows(4).Cells(1).Range.InsertBefore ("Restore:")

iTable.Rows(1).Cells(2).Range.Select

End Sub

今、私がする必要があるのは、私が望むようにテーブルをフォーマットし、ドキュメント内のテーブルのセットを介して番号を昇順にする方法を理解することです。

于 2012-03-30T19:04:08.180 に答える