[英]How to change font size excluding headings,sub headings, TOC ,Title using VBA macro in word document
[英]How to change the font size of all tables in a word document using a vba macro
我有一個包含很多表格的 word 文檔。 我想要一個宏,它將所有表格的字體大小更改為 10,將每個表格自動調整到窗口並均勻分布列。 我可以使用下面的代碼完成最后兩個目標,但不確定如何更改字體大小。 任何幫助將不勝感激。
Sub changetables()
Dim tbl As Table
For Each tbl In ActiveDocument.Tables
tbl.AutoFitBehavior wdAutoFitWindow
tbl.Columns.DistributeWidth
Next
End Sub
對於您的確切代碼使用
tbl.Range.Font.Size = 12
我重新輸入了一些內容以顯示更好的命名和間距等。
Sub changetables()
Dim CurrentTable As Table
For Each CurrentTable In ActiveDocument.Tables
With CurrentTable
.AutoFitBehavior wdAutoFitWindow
.Columns.DistributeWidth
.Range.Font.Size = 12
End With
Next CurrentTable
End Sub
只需將 .size 更改為 .name,如 tbl.Range.Font.Name = "Calibri"
這也適用於您希望使用的任何字體名稱,方法是將雙引號內的 Calibri 替換為您想要的字體名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.