简体   繁体   English

word中单元格高度和inlineShape高度的区别

[英]Difference between cell height and inlineShape height in word

I have a chart that I copied from excel into a word table cell.我有一个从 excel 复制到 word 表格单元格中的图表。 Now I am trying to resize it.现在我正在尝试调整它的大小。 Due to company rules I have to use access-vba for all of that.由于公司规定,我必须使用 access-vba 来完成所有这些。

This line resizes the graph alright ...这条线可以调整图形的大小...

wdDoc.inlineShapes(1).ScaleHeight = (wdDoc.Tables(3).Cell(2,1).Height)

but

MsgBox (wdDoc.Tables(3).Cell(2,1).Height)    '= 410
MsgBox (wdDoc.inlineShapes(1).Height)        '= 942.65

Why is there a resize to an arbitrary number?为什么要调整为任意数字? The Width is 1393,3 pts so it is no confusion between width and height ...宽度为 1393,3 pts,因此宽度和高度之间不会混淆......

I think I found the answer:我想我找到了答案:

inlineShape.ScaleHeight: Scales the height of the specified inline shape relative to its original size. inlineShape.ScaleHeight:相对于其原始大小缩放指定的内联形状的高度。

That means that I did not scale it to 410 points of height but just to 410 percent of its former height.这意味着我没有将它缩放到 410 点的高度,而只是缩放到它之前高度的 410%。

The solution to my problem is to use .height and .width and calculate a ratio first.我的问题的解决方案是使用.height.width并首先计算一个比率。

Dim sizeRatio as Double

With .inlineShapes(1)

    sizeRatio = .Height / .Width
    .Height = wdDoc.Tables(3).Cell(2,1).Height
    .Width = wdDoc.Tables(3).Cell(2,1).Height / sizeRatio

End With

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM