Powerpoint VBA - 如何将文本框添加到多张幻灯片 [英] Powerpoint VBA - How to add text box to multiple slides
本文介绍了Powerpoint VBA - 如何将文本框添加到多张幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我使用以下代码在几张幻灯片的标题中添加一个文本框:
So I'm using the following code to add a text box to the header of several slides:
Set myDocument = ActivePresentation.Slides.Range(Array(4, 5, 6))
Set newTextBox = myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
260, Top:=30, Width:=541.44, Height:=43.218)
With newTextBox.TextFrame.TextRange
.Text = "Test Text"
.Font.Size = 17
.Font.Name = "Arial"
End With
当我运行此代码时,我收到一个自动化错误并且它不起作用.如果我在一张幻灯片上做它确实有效.有谁知道为什么?我试图做的是向特定幻灯片添加标题.所以我将使用相同的方法向其他幻灯片添加不同的标题.
When I run this code I get an automation error and it doesn't work. If I do it on a single slide it does work. Does anyone know why? What I'm attempting to do is add headers to specific slides. So I will be using the same method to add different headers to other slides as well.
推荐答案
您可以使用您设置的数组中的数字浏览所有幻灯片:
You can go through all the slides with numbers from the array you set:
Sub slideTextBoxes()
For Each myDocument In ActivePresentation.Slides.Range(Array(4, 5, 6))
Set newTextBox = myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
260, Top:=30, Width:=541.44, Height:=43.218)
With newTextBox.TextFrame.TextRange
.Text = "Test Text"
.Font.Size = 17
.Font.Name = "Arial"
End With
Next
End Sub
这篇关于Powerpoint VBA - 如何将文本框添加到多张幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文