gpt4 book ai didi

VBA PowerPoint 文本框文本对齐

转载 作者:行者123 更新时间:2023-12-02 11:52:28 25 4
gpt4 key购买 nike

我正在使用 PowerPoint 2007,我想编写一个在幻灯片中创建文本框的宏。

但是,文本框中的文本默认居中对齐。

我想将其左对齐,但我不知道该怎么做。如何更改此文本框的对齐方式?

这是我的代码。

Set objPPT = CreateObject("PowerPoint.Application")
Set SQ = objPPT.Presentation

......

SQ.Slides(i + 6).Shapes.AddTextbox(msoTextOrientationHorizontal, 50, 100, 600, 100).Select
objPPT.ActiveWindow.Selection.TextRange.Text = titre

最佳答案

首先,选择代码中的任何内容或依赖当前选择通常都不是好的做法,因为它会使代码速度减慢几个数量级。

相反,像这样:

Dim oSh as Object ' if you're using late binding, as Shape if early binding

Set oSh = SQ.Slides(i + 6).Shapes.AddTextbox(msoTextOrientationHorizontal, 50, 100, 600, 100)
' notice that I've removed the .Select from the end of the line above

With oSh.TextFrame
.TextRange.Text = "something"
.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignLeft
End With

关于VBA PowerPoint 文本框文本对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11541475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com