我使用這段代碼:
Sub d_FormatTableEndNoteDemo2()
Application.ScreenUpdating = False
Dim Tbl As Table
For Each Tbl In ActiveDocument.StoryRanges(wdEndnotesStory).Tables
With Tbl
.AllowAutoFit = False
.Rows.Alignment = wdAlignRowCenter
.Rows.Height = CentimetersToPoints(0.6)
.Range.Cells.VerticalAlignment = wdCellAlignVerticalTop
.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Columns(1).Width = CentimetersToPoints(1#)
.Columns(2).Width = CentimetersToPoints(5#)
.Columns(3).Width = CentimetersToPoints(11#)
End With
Next
Application.ScreenUpdating = True
End Sub
但我不知道如何格式化第三列的字體=隱藏。請幫我。
uj5u.com熱心網友回復:
除了 Excel,您無法訪問 Word 中的列范圍。在這種情況下,您需要遍歷特定列的所有單元格:
Public Sub hideTextInColumn(tbl As Table, columnIndex As Long)
Dim c As Cell
For Each c In tbl.Columns(columnIndex).Cells
c.Range.Font.Hidden = True
Next
End Sub
你會打電話給這個子hideTextInColumn tbl, 3
在你的日常生活中:
Sub d_FormatTableEndNoteDemo2()
Application.ScreenUpdating = False
Dim Tbl As Table
For Each Tbl In ActiveDocument.StoryRanges(wdEndnotesStory).Tables
With Tbl
.AllowAutoFit = False
.Rows.Alignment = wdAlignRowCenter
.Rows.Height = CentimetersToPoints(0.6)
.Range.Cells.VerticalAlignment = wdCellAlignVerticalTop
.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Columns(1).Width = CentimetersToPoints(1#)
.Columns(2).Width = CentimetersToPoints(5#)
.Columns(3).Width = CentimetersToPoints(11#)
'---- new
hideTextInColumn tbl, 3
'----
End With
Next
Application.ScreenUpdating = True
End Sub
``
uj5u.com熱心網友回復:
以下子格式表格第 3 列中的單元格:
Sub FormatTableColumn()
Dim tbl As Word.Table
Set tbl = ActiveDocument.Tables(1)
tbl.Columns(3).Select
With Selection.Font
.Name = "Times New Roman"
.Size = 10
.Hidden = True
End With
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/486701.html
下一篇:處理字串和復制粘貼變數