Excel/VBA:在 vba/excel 中更改圆角矩形的圆度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5146210/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:45:16  来源:igfitidea点击:

Excel/VBA: change roundness of a rounded rectangle in vba/excel

excelvbaexcel-vbaexcel-2007

提问by Kimball Robinson

I am trying to figure out how to change the roundness of a rounded rectangle shape in Excel using VBA.

我想弄清楚如何使用 VBA 在 Excel 中更改圆角矩形形状的圆度。

I started out by creating the rounded rectangle, but at this point I'm not sure what to do next.

我从创建圆角矩形开始,但此时我不确定下一步该怎么做。

Set roundedRec = ws.Shapes.AddShape(msoShapeRoundedRectangle, 10, 10, 200, 40) 

I've googled for vba shapes roundness rounded, excel vba rounded rectangle corner radiusand other similar phrases, but haven't found anything terribly instructive or helpful. I'm beginning to think I can't change this property via visual basic, though I can do it through Excel's GUI.

我在谷歌上搜索了vba shapes roundness rounded,excel vba rounded rectangle corner radius和其他类似的短语,但没有找到任何非常有启发性或帮助的东西。我开始认为我无法通过 Visual Basic 更改此属性,尽管我可以通过 Excel 的 GUI 进行更改。

采纳答案by mellamokb

I googled msoShapeRoundedRectangle radius, and the first linkhad an example:

我用谷歌搜索msoShapeRoundedRectangle radius,第一个链接有一个例子:

With oSh
    oSh.AutoShapeType = msoShapeRoundedRectangle
    .Adjustments(1) = sngRounding
End With

回答by chris neilsen

The shape object has a Fill property which has methods

形状对象有一个 Fill 属性,该属性有方法

.OneColorGradient(Style, Variant, Degree)

.TwoColorGradient(Style, Variant)

.OneColorGradient(样式,变体,度数)

.TwoColorGradient(样式,变体)

examle of use

使用示例

Set shp = ActiveSheet.Shapes("Rounded Rectangle 1")
shp.Adjustments(1) = shp.Adjustments(1) * 2

shp.Fill.ForeColor.RGB = RGB(0, 0, 128)

shp.Fill.OneColorGradient msoGradientHorizontal, 1, 1