我写了一个宏,将excel中的表格复制到word中。在excel中,所有的列都有不同的宽度。在Word中,我想把我的表格放在一页纸上--Word的页边距从左到右都是1.5厘米。我的表格中的行数发生了变化,而列数是稳定的(这是14)。如何设置列宽相等?我想知道是否可以不考虑标题中文字的数量,设置相同的列宽。我创建了swdth变量,然后除以14(我所有的列),我的表在一页上......
这段代码不能正常工作。我的所有行都在一个页面上,但是列的宽度不同。
Table.Rows.SetHeight RowHeight:=InchesToPoints(0.17), HeightRule:=wdRowHeightExactly
Table.Rows(1).SetHeight RowHeight:=InchesToPoints(0.59), HeightRule:=wdRowHeightExactly
sWdth = InchesToPoints(6.22)
WordTable.PreferredWidthType = wdPreferredWidthPoints
WordTable.PreferredWidth = sWdth
sWdth = sWdth / 14
给所有的列都是一样的与是简单的。
Table.Columns.DistributeWidth
但是不知道这和把表格放在一页上有什么关系。
我最近也看到类似的问题。 一如既往的...
#1) Turn on the Macro Recorder
#2) Click through the steps you need to perform
#3) Turn off the Macro Recorder
点击Alt+F11,你应该会看到所有你想做的事情所需要的代码。 记住,Macro Recorder是你的朋友!