[英]VBA Picture Shadow Macro
I have a bunch of images that I would like to apply a specific picture style to - the 4th one that is shown in Word 2010:我有一堆图像,我想应用特定的图片样式 - 第 4 个显示在 Word 2010 中:
I have a macro that will loop through all images, but need to know the possibilities for the shadow.type.我有一个循环遍历所有图像的宏,但需要知道 shadow.type 的可能性。
What would be really helpful is a reference to the commands that would be used for each type of picture style, with a visual example.真正有用的是参考将用于每种图片样式的命令,并提供一个可视化示例。
I don't have VBA, so can't examine the elements of the picture.我没有 VBA,所以无法检查图片的元素。 I have tried various msoShadowxx, but that didn't work.
我尝试了各种 msoShadowxx,但没有用。
Is there a good reference with visual examples, or a reference with the settings for each picture style?是否有很好的视觉示例参考,或每种图片样式设置的参考? Or the settings to use for the 4th picture style (shown in the screenshot here)?
或用于第 4 种图片样式的设置(如此处的屏幕截图所示)?
Here is the macro code that I use to loop through all the pictures.这是我用来遍历所有图片的宏代码。
Sub BorderMacroshadow()
Dim oInlineShp As InlineShape
For Each oInlineShp In ActiveDocument.InlineShapes
With oInlineShp
.Line.Weight = 1
.Line.ForeColor.RGB = vbBlack
.Shadow.Type = msoShadow14
End With
Next
End Sub
Added添加
A closer look at the reference for msoShadow shows that it is referring to Picture Effects, Shadows 'dialog', not the 'Picture Styles', which I assumes uses some elements of msoShadow in addition to other elements.仔细查看 msoShadow 的参考资料会发现它指的是图片效果、阴影“对话框”,而不是“图片样式”,我假设除了其他元素外,它还使用了 msoShadow 的一些元素。
So, I am looking for the elements that are needed to duplicate the 4th 'Picture Style' (see the screenshot).因此,我正在寻找复制第 4 个“图片样式”所需的元素(参见屏幕截图)。 Haven't found those yet.
还没有找到那些。
The msoShadowType
enumeration is a group of pre-sets. msoShadowType
枚举是一组预设。 These aren't necessarily used in the gallery on the Ribbon.这些不一定在功能区的图库中使用。
In order to ascertain the settings of any Shadows formatting use the various properties available for Shape.Shadow
, such as Transparency
, Size
, Blur
.为了确定任何阴影格式的设置,请使用
Shape.Shadow
可用的各种属性,例如Transparency
、 Size
、 Blur
。 Inthe UI, these can be seen in Picture Effects, Shadow, Shadow Options of the Picture Style group on the Ribbon.在用户界面中,这些可以在功能区图片样式组的图片效果、阴影、阴影选项中看到。
To determine/set them programmatically, see the following code sample.要以编程方式确定/设置它们,请参阅以下代码示例。 Note that
Angle
is not one property, but a combintation of OffsetX
and OffsetY
.请注意,
Angle
不是一个属性,而是OffsetX
和OffsetY
的组合。
Sub ShadowProperties()
Dim shp As Word.Shape
Dim shw As Word.ShadowFormat
Set shp = Selection.ShapeRange(1)
Set shw = shp.Shadow
With shw
Debug.Print "Blur: " & .Blur, _
"size: " & .Size, _
"Transparency: " & .Transparency, _
"Offset x: " & .OffsetX, _
"Offset y: " & .OffsetY
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.