geekswg

word 设置表格自适应

描述 : 我们经常从 外部 如 excel,html 等其他文件 中复制的表格到word 文档 出现在 word 中显示不全的问题

 

解决方案 使用 word 宏工具

在当前word文档中 按 alt + F11 快捷键

然后

 

 

 附 图中代码如下:(尽情的复制吧)

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

分类:

技术点:

相关文章:

  • 2021-06-05
  • 2022-03-10
  • 2022-12-23
  • 2021-07-10
  • 2021-11-29
  • 2021-09-23
猜你喜欢
  • 2021-12-08
  • 2022-12-23
  • 2021-12-12
  • 2021-12-26
  • 2022-01-05
  • 2021-11-19
相关资源
相似解决方案