如何使用vba在powerpoint中执行复制粘贴操作时保持文本格式?

发布于 2025-01-01 09:29:28 字数 620 浏览 2 评论 0原文

在我的最后一个问题中“使用vba从powerpoint中的文本中查找数字?”,我做了一个代码&它工作得很好(感谢Tony Dallimore)。但在这个过程中,我遇到了一些意想不到的事情,例如:

  1. 如果我的文本框包含带有项目符号和符号的文本。子子弹。
  2. 如果它包含带有某种字体颜色的http链接。

然后运行我的代码后。它向我显示没有任何文本格式的数据,如上面指定的文本格式消失了。

现在我知道为什么会这样了。因为在我的代码中,我将所有文本收集到一个变量中然后执行action然后替换成ppt中的旧的。

所以我的问题是“有没有办法在文本框中运行代码,这样提到的问题就会得到解决?”

有关代码,请转到上一个问题

谢谢

In my last question "Find number from text in powerpoint using vba?", I made a code & its working perfectly (thanks to Tony Dallimore). But in this process i am facing some unexpected things like :

  1. If my textbox contain text with bullets & sub bullets.
  2. If it contains http links with some font color.

Then after running my code. it shows me data without any text formatting like above specified text formatting is vanish.

Now i know why this happen. Because in my code i collect all text into one variable & then perform action and then replace it to the old one in ppt.

So my question "Is there any way to run code within the textbox, so mentioned problem will be solved?"

For code please go to the previous question.

Thanks

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

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

发布评论

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

评论(1

╰◇生如夏花灿烂 2025-01-08 09:29:28

更多的是提示而不是答案:

范围对象有一个“.duplicate”属性 - 它复制格式。看看这是否可以应用于您的场景。

例如。

创建一个新文档。以您满意的方式格式化第一段。然后:

set dup = ActiveDocument.Paragraph(1).Format.Duplicate

Documents.Add
Selection.InsertAfter "This is a new paragraph."
Selection.Paragraphs.Format = dup

新页面中的文本将按照以前的格式设置

more of a hint than an answer:

range objects have a ".duplicate" property - which copies the formatting. See if this can be applied to your scenario.

eg.

create a new document. Format the first paragraph in a way that pleases you. then:

set dup = ActiveDocument.Paragraph(1).Format.Duplicate

Documents.Add
Selection.InsertAfter "This is a new paragraph."
Selection.Paragraphs.Format = dup

the text in the new page will be formatted as before

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