vba - 你如何创建一个黄色的文本框?
问题描述
你如何创建一个黄色的文本框?
我尝试了下面的方法,但我不能这样做 a) 它在活动幻灯片中执行它,b) 它是黄色的(可能带有一些格式作为阴影)谢谢
Sub sticky()
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=100, Top:=100, Width:=200, Height:=50).TextFrame _
.TextRange.Text = "Test Box"
End Sub
解决方案
使用 ActiveWindow.Selection.SlideRange(1) 而不是 ActivePresentation.Slides(1) 通常会为您提供所需的幻灯片参考。
初学者试试这个:
Sub sticky()
' Use object variables for slide and shape
Dim oSl as Slide
Dim oSh as Shape
' Get a reference to the current slide
Set oSl = ActiveWindow.Selection.SlideRange(1)
' Add the shape and get a reference to it:
Set oSh = oSl.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=100, Top:=100, Width:=200, Height:=50)
With oSh
.TextFrame.TextRange.Text = "Test Box"
.Fill.ForeColor.RGB = RGB(255, 255, 0)
' Add any other formatting to the shape here
End With ' oSh ... the shape you added
End Sub
推荐阅读
- javascript - TypeError:无法读取未定义的属性“会话”
- python - 有没有办法在移动网站上向下滚动或触发无限滚动加载?
- regex - 如何使用表达式解析电子邮件中的数据?
- python-3.x - 如何根据字典的长度对数据框进行子集化?
- pandas - 如何计算 Pandas 数据框中一列中两个重复值之间的单元格距离(例如索引)?
- docker - Cassandra CQL (cqlsh) docker 容器到 docker Cassandra 集群
- r - 在 r 中重新排列数据帧
- android - Android 应用程序在发布版本时崩溃,但在调试版本中工作 - React-Native
- selenium - 在 XRAY 测试执行中上传 JSON 文件以生成最终报告时出错
- c# - 在 Unity 2D 中进行空投攻击