0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WordVBAで表の操作

Posted at

アクティブなページのテーブルを選択

'アクティブなページのテーブルを選択する。
    With ActiveDocument.Bookmarks("\Page").Range.Tables
     If .Count = 0 Then Exit Sub
        .Item(1).Select
    End With

表内の文字サイズ,デザイン,行間の指定

'例はサイズ7p , デザインは"MS Pゴシック"
    With Selection.Range.Font
        .Size = 7
        .Name = "MS Pゴシック"
    End With
    
'例は行間8p固定
    With Selection.ParagraphFormat
        .LineSpacingRule = wdLineSpaceExactly
        .LineSpacing = 8
    End With

表内の全セルを垂直方向中央揃え

 Dim rowMax As Long, i As Long
 rowMax = ActiveDocument.Bookmarks("\Page").Range.Tables.Item(1).Rows.Count
 For i = 1 To rowMax
    With ActiveDocument.Bookmarks("\Page").Range.Tables.Item(1).Rows(i)
        .Cells.VerticalAlignment = wdCellAlignVerticalCenter 
    End With
Next

行の高さを変更

'1行目を7.5mmに変更
Call ActiveDocument.Bookmarks("\Page").Range.Tables.Item(1).Rows(1).SetHeight(MillimetersToPoints(7.5), wdRowHeightExactly)

列の幅を変更

'1列目を8mmに変更
Call ActiveDocument.Bookmarks("\Page").Range.Tables.Item(1).Columns(1).SetWidth(MillimetersToPoints(8), wdAdjustNone)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?