将特殊符号从一个 PowerPoint 演示文稿复制到另一个 PowerPoint 演示文稿
我需要将文本从一个 PowerPoint 演示文稿复制到另一个演示文稿。但是,我在复制特殊符号(例如笑脸)时遇到问题,这些符号在目标演示文稿中显示为空框。查看原始演示文稿中的 Open XML 文件,我可以看到包含笑脸的 Run
有一个“SymbolFont”属性:
但是,在 VBA 中,Shape.TextFrame2.TextRange2.Font
= Run
的字体 - 显示 Arial。
如何使用 VBA 或 C#(而非 XML)确定文本 Run
的 SymbolFont? 然后我可以在目标演示文稿中指定该 SymbolFont。
也许还有其他不涉及 XML 的复制文本的方法?
请注意,这个问题不仅发生在表情符号上,还发生在表情符号上。其他特殊字符可能会显示不同的SymbolFonts,例如:
<a:symTypeface = "Symbol", PitchFamily = 18, CharacterSet = 2>
代码示例:
getRuns(TextRange2 paragraph)
{
foreach(TextRange2 run in paragraph.get_Runs(-1,-1))
_myRuns.Add(new MyRun {_text=run.Text, _font=run.Font} );
}
copyRunsToParagraph(TextRange2 paragraph)
{
foreach(MyRun run in _myRuns)
paragraph=paragraph.InsertAfter(run._text);
}
注意:Run.Font
似乎仅返回拉丁字体,而不返回Symbol 字体,例如Arial 而不是Wingdings。正如我所写,不同的符号可能有不同的 SymbolFonts,因此始终使用 Wingdings 是行不通的。
I need to copy text from one PowerPoint presentation to another. However, I have problems copying special symbols, such as smileys, which appear in the target presentation as empty boxes. Looking at the Open XML file in the original presentation, I can see that the Run
containing the smiley has a "SymbolFont" attribute:
<a:sym typeface="Wingdings" />
However, in VBA, Shape.TextFrame2.TextRange2.Font
=the Font of that Run
- shows Arial.
How can I determine the SymbolFont of a text Run
using VBA or C# (not XML)?
Then I could specify that SymbolFont in the target presentation.
Perhaps there other ways for copying the text that do not involve XML?
Note that this problem happens not only with Smileys; other special characters may show different SymbolFonts, such as:
<a:symTypeface = "Symbol", PitchFamily = 18, CharacterSet = 2>
Code example:
getRuns(TextRange2 paragraph)
{
foreach(TextRange2 run in paragraph.get_Runs(-1,-1))
_myRuns.Add(new MyRun {_text=run.Text, _font=run.Font} );
}
copyRunsToParagraph(TextRange2 paragraph)
{
foreach(MyRun run in _myRuns)
paragraph=paragraph.InsertAfter(run._text);
}
Note: Run.Font
seems to return only the Latin font, not the Symbol font, e.g., Arial but not Wingdings. As I wrote, different symbols may have different SymbolFonts, so always using Wingdings does not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这无法在 VBA 中完成。
This can't be done in VBA.