[英]VBA - Power Point - Wrap text in Shape programmatically
I have been working on a small hack around with Power Point to automatically create a Text Box Shape with some preset effect in which the text is dynamically fetched from clipboard. 我一直在与Power Point一起进行小型黑客工作,以自动创建具有某些预设效果的文本框形状,在这种效果中,可以从剪贴板中动态获取文本。 I have quiet a bit of a problem here, the functionality works fine with the following VB script with macros.
我这里有一个问题,该功能在以下带有宏的VB脚本中可以正常使用。
Sub ReadFromFile()
' CLIPBOARD
Dim MyData As DataObject
Dim strClip As String
' CLIPBOARD
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText
Set activeDocument = ActivePresentation.Slides(1)
With activeDocument
'Set QASlide = .Slides.Add(Index:=.Slides.Count + 0, Layout:=ppLayoutBlank)
activeDocument.Shapes.AddTextEffect PresetTextEffect:=msoTextEffect28, _
Text:=strClip, _
FontName:="Garde Gothic", FontSize:=44, FontBold:=msoTrue, _
FontItalic:=msoFalse, Left:=25, Top:=25
With .Shapes(.Shapes.Count)
.Width = 200
.Height = 300
End With
End With
End Sub
Can some one help me in providing the script for wrapping the text inside the shape which has a defined width and height as in the code above? 有人可以帮我提供用于将文本包装在形状和宽度都一样的形状内的脚本的方法吗?
I think you are looking for this: 我认为您正在寻找:
.Shapes(.Shapes.Count).TextFrame.TextRange.Text = strClip
You can set it in the same With
that you are setting the height and width 你可以将它设置在同一
With
您正在设置的高度和宽度
Not sure if I understand you right but does adding .TextFrame.WordWrap = msoTrue
to the block below solve your problem? 不知道我是否理解正确,但是在下面的块中添加
.TextFrame.WordWrap = msoTrue
可以解决您的问题?
With .Shapes(.Shapes.Count)
.Width = 200
.Height = 300
End With
如果要使文本环绕在形状中,则必须使用文本效果形状以外的其他东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.