word 批量設置表格寬度自適應
描述 :
我們經常從 外部 如 excel,html 等其他文件 中復制的表格到word 文檔 經常會出現在 word 中顯示不全的問題
主要是源格式的表格 寬度比 word 文檔頁面要大,就會導致 表格無法正常顯示所有數據
解決方案
使用 word 宏工具 批量設置 word 文檔中的 表格寬度自適應,即可解決問題!
打開宏編輯器
在當前word文檔中 按 alt + F11 快捷鍵 打開 word 宏編輯器 是 vb 語言。
然后 步驟如下圖 所示
直接上代碼
附 圖中代碼如下:(盡情的復制吧)
Private Sub Document_Open() Application.Browser.Target = wdBrowseTable For i = 1 To ActiveDocument.Tables.Count ActiveDocument.Tables(i).AutoFitBehavior (wdAutoFitContent) '根據內容自動調整表格 ActiveDocument.Tables(i).AutoFitBehavior (wdAutoFitWindow) '根據窗口自動調整表格 ActiveDocument.Tables(i).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '水平居中 ActiveDocument.Tables(i).Range.ParagraphFormat.Alignment = wdCellAlignVerticalCenter '垂直居中 Next i End Sub
附代碼如下
注意一定不要忘記 點擊 保存按鈕
方法緣於 博客園大神 傳送門:https://www.cnblogs.com/jiangxin/p/5579885.html
Word 的 宏工具真的有用呀,office 學無止境