使用 VBA 更改 Powerpoint 演示文稿中的默认文本方向

发布于 2024-09-06 14:46:15 字数 869 浏览 5 评论 0原文

我使用 Powerpoint 对象模型以编程方式在 PowerPoint 2007 中创建演示文稿。

我运行程序的一些计算机将 PowerPoint 设置为希伯来语作为主要编辑语言。 (要更改主要语言,请按“Office”按钮,然后按“Powerpoint 选项”,然后转到“流行”->“语言设置”->“主要编辑语言”)

在这些计算机上,当我运行程序时,所有文本都会显示在创建的演示文稿(错误地)显示为右对齐,并且项目符号显示在文本的右侧。

我可以通过编辑生成的演示文稿 PPTX 文件中的 ppt/presentation.xml 来解决此问题。我调整每个项目符号级别的“默认文本样式”中的 Alignment 和 RightToLeft 属性。然而,XML 编辑对于这个项目来说并不是一个好的选择。

除了单独更改每个文本框之外,如何使用对象模型(即 VBA)更改演示文稿中的默认文本方向?


感谢您的建议,

我尝试过:

我执行了 Application.Presentations(1).LayoutDirection = ppDirectionLeftToRight,这改变了 PowerPoint 用户界面的方向。我还将 Application.Presentations(1).LanguageID 更改为美国英语。 不幸的是,做这些事情并没有解决创建的演示文稿中从右到左文本的问题。

所以最后我放弃了更改演示文稿本身的参数,实际上直接更改了每个 RunParagraphFormat.TextDirectionParagraphFormat.Alignment我最初试图避免使用 TextBox,这自然达到了预期的效果。

I use the Powerpoint Object-Model to programmatically create a presentation in PowerPoint 2007.

Some of the computers on which I run my program have PowerPoint set with Hebrew as the Primary Editing Language.
(to change the primary language, push the "Office" button, then "Powerpoint options", and go to Popular->Language Settings->Primary Editing Language)

On these computers, when I run my program, all the text in the created presentation (wrongly) appears right-justified and the bullets appear to the right of the text.

I could fix this by editing the ppt/presentation.xml in the resulting presentation PPTX file. I adjust the Alignment and RightToLeft properties in the "Default Text Styles" for each bullet level. However, XML editing is not a good option for this project.

How can I change the default text direction in a presentation using the Object Model (i.e., VBA), besides changing each TextBox individually?


Thanks for the suggestions,

What I tried:

I performed Application.Presentations(1).LayoutDirection = ppDirectionLeftToRight, which changes the direction of the PowerPoint user-interface. I also changed Application.Presentations(1).LanguageID to US English.
Unfortunately, doing these things did not solve the problem of the right-to-left text in the created presentation.

So finally I gave up on changing the parameters for the Presentation itself and indeed directly changed ParagraphFormat.TextDirection and ParagraphFormat.Alignment for each Run of each TextBox which I initially tried to avoid, and naturally this had the desired effect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼睛会笑 2024-09-13 14:46:15

在 C# 中,它看起来像这样:

textbox.TextFrame.TextRange.ParagraphFormat.TextDirection = PpDirection.ppDirectionRightToLeft

In C# it will look this way:

textbox.TextFrame.TextRange.ParagraphFormat.TextDirection = PpDirection.ppDirectionRightToLeft
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文