vba 以编程方式设置图表的不移动或大小与单元格属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22362435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Programmatically set the Don't Move or Size with Cells property for a Chart
提问by neizan
Using Excel 2007 VBA. I have a single Chart on a sheet that overlaps its source data. When cleaning up I hide the data rows, but the Chart is shrinking in height.
使用 Excel 2007 VBA。我在与其源数据重叠的工作表上有一个图表。清理时我隐藏了数据行,但图表的高度正在缩小。
I know I can set the "Don't move or size with cells" to True, but I don't know how to do this programmatically from VBA. I tried just recording a macro, but it didn't show up.
我知道我可以将“不要移动或调整单元格大小”设置为 True,但我不知道如何从 VBA 以编程方式执行此操作。我试着只录制一个宏,但它没有出现。
采纳答案by neizan
I could have been a little more specific in my question by indicating that I had access to a ChartObject
object in VBA. Therefore, when I came across various examples on the internet using Shape.Placement = vbFreeFloating
, I wasn't sure how to use it on a ChartObject
. As I mentioned in a comment above, this pagementions that you can access the Shape
associated with a ChartObject
by the using ChartObject.Parent
property. Then it's simply a matter of doing ChartObject.Parent.Placement = vbFreeFloating
. This appears to have solved my problem. Hope it helps someone else.
通过表明我可以访问ChartObject
VBA 中的对象,我可以在我的问题中更具体一点。因此,当我在互联网上遇到各种使用 的示例时Shape.Placement = vbFreeFloating
,我不确定如何在ChartObject
. 正如我在上面的评论中提到的,此页面提到您可以通过 using属性访问Shape
与 a 相关联的。那么这只是一个做的问题。这似乎解决了我的问题。希望它可以帮助别人。ChartObject
ChartObject.Parent
ChartObject.Parent.Placement = vbFreeFloating