Powerpoint 2016文本透明度(Powerpoint 2016 Text Transparency)

编程入门 行业动态 更新时间:2024-10-27 20:29:45
Powerpoint 2016文本透明度(Powerpoint 2016 Text Transparency)

我需要通过VBA在一个形状中设置文本的透明度,实际上我需要设置整个形状的透明度,但它是我坚持的文本。

我似乎无法导航对象模型以找到透明属性

Function SetTransparency(Value As Single) On Error GoTo AbortNameShape If ActiveWindow.Selection.ShapeRange.Count = 0 Then MsgBox "No Shapes Selected" Exit Function End If With ActiveWindow.Selection.ShapeRange .Fill.Transparency = Value .Line.Transparency = Value .TextFrame.TextRange. **HELP** .Transparency = Value End With AbortNameShape: MsgBox Err.Description End Function

谷歌给了我

.TextFrame.TextRange.Characters.Font.Fill.Transparency

来自https://www.mrexcel.com/forum/excel-questions/510589-transparent-text-shapes-textbox-1-a.html

但是在Font对象的.Fill属性不存在时失败了。 我假设MS已经在给出答案后的10年内改变了对象模型,但我仍然坚持当前的方法。

谢谢

I need to set the Transparency of Text in a shape via VBA, in fact I need to set the transparency for the whole shape but it's the text I'm stuck with.

I just can't seem to navigate the object model to find the Transparency Property

Function SetTransparency(Value As Single) On Error GoTo AbortNameShape If ActiveWindow.Selection.ShapeRange.Count = 0 Then MsgBox "No Shapes Selected" Exit Function End If With ActiveWindow.Selection.ShapeRange .Fill.Transparency = Value .Line.Transparency = Value .TextFrame.TextRange. **HELP** .Transparency = Value End With AbortNameShape: MsgBox Err.Description End Function

Google has given me

.TextFrame.TextRange.Characters.Font.Fill.Transparency

From https://www.mrexcel.com/forum/excel-questions/510589-transparent-text-shapes-textbox-1-a.html

But that fails on the .Fill property of Font object not existing. I'm assuming MS have changed the object model in the 10 years that have passed since the answer was given, but I'm stuck for a current approach.

Thanks

最满意答案

试试这个(仅适用于当前选择的第一个成员)

With ActiveWindow.Selection.ShapeRange(1) With .TextFrame2.TextRange.Font.Fill .Transparency = 0.5 End With End With

如果要遍历当前选择中的所有形状,则需要测试每个形状,以查看.HasTextFrame和.TextFrame.HasText在尝试使用文本之前是否为真。

Try this (for just the first member of the current selection)

With ActiveWindow.Selection.ShapeRange(1) With .TextFrame2.TextRange.Font.Fill .Transparency = 0.5 End With End With

If you want to iterate through all the shapes in the current selection, you'll want to test each shape to see if .HasTextFrame and .TextFrame.HasText are true before trying to work with the text.

更多推荐

本文发布于:2023-08-07 10:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463338.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:透明度   文本   Powerpoint   Text   Transparency

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!