我可以用原始文本定义幻灯片或演示文稿吗?

发布于 2024-12-09 15:30:04 字数 154 浏览 0 评论 0原文

大家好:我想使用原始文本文件创建一个 Power Point 演示文稿,以便我可以快速编辑文件并查看结果,并保证统一的格式。基本上,我正在谈论将数据内容与演示文稿分开。

我该怎么做?我想乳胶也许是一个选择。我还看到有用于 Powerpoint 和开放式办公室演示文稿的 API。

Hi Guys : I wanted to create a power point presentation using a raw text file, so that i can rapidly edit the file and see the results, gauranteed with uniform formatting. Basically, I'm talking about separating the data content from the presentation.

How can I do this ? Im thinking that maybe Latex could be a choice. I've also seen that there are API's for Powerpoint and open office presentations.

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

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

发布评论

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

评论(2

过期以后 2024-12-16 15:30:04

Powerpoint 通过 COM 公开它的 API - 这使得您可以使用任何支持 COM 的编程语言在 GUI 中执行(几乎)任何操作。困难在于 API 在版本之间发生变化。确定 API 范围的一种方法是使用宏录制工具手动制作一张幻灯片,然后将其翻译为您的目标语言。

我有一些旧的(最近未测试过)Powerpoint 2003 的Python 代码,您可以根据自己的布局需求了解代码的外观。

from win32com.client import Dispatch

ppLayoutTitle = 1
ppLayoutText  = 2

def writePresentation( fname, data ):
    pptApp = Dispatch('Powerpoint.Application')
    pres   = pptApp.ActivePresentation
    aw     = pptApp.ActiveWindow
    slides = pres.Slides

    for item in data:
        t1 = item[0]
        t2 = item[1]
        stype = item[2]
        assert(stype in [ppLayoutTitle,ppLayoutText])
        s = slides.Add( slides.Count, stype )
        aw.View.GotoSlide(s.SlideIndex)

        s.Shapes.Item(1).Select()
        aw.Selection.ShapeRange.TextFrame.TextRange.Select()
        aw.Selection.ShapeRange.TextFrame.TextRange.Characters(Start=1, Length=0).Select
        tr = aw.Selection.TextRange
        tr.Text = t1

        s.Shapes.Item(2).Select()
        aw.Selection.ShapeRange.TextFrame.TextRange.Select()
        if stype == ppLayoutText:
            aw.Selection.ShapeRange.TextFrame.TextRange.ParagraphFormat.Bullet.Visible = 0
        aw.Selection.ShapeRange.TextFrame.TextRange.Characters(Start=1, Length=0).Select
        tr = aw.Selection.TextRange
        tr.Text = t2
    slides.Range(slides.Count).Delete()
    pres.SaveAs(fname)

编辑:

Openoffice(可以导出到 powerpoint)还附带其脚本 API 可用于解决类似问题。

Powerpoint exposes it's API via COM - which makes it possible to do (almost) anything that you can do in the GUI in any programming language that supports COM. The difficulty is that the API changes between releases. One way to scope out the API is to use the macro recording facility to manually do one slide, and then translate that to your target language.

I've got some old (not tested recently) python code for Powerpoint 2003 that should give you an idea of what the code might look like depending on your layout needs.

from win32com.client import Dispatch

ppLayoutTitle = 1
ppLayoutText  = 2

def writePresentation( fname, data ):
    pptApp = Dispatch('Powerpoint.Application')
    pres   = pptApp.ActivePresentation
    aw     = pptApp.ActiveWindow
    slides = pres.Slides

    for item in data:
        t1 = item[0]
        t2 = item[1]
        stype = item[2]
        assert(stype in [ppLayoutTitle,ppLayoutText])
        s = slides.Add( slides.Count, stype )
        aw.View.GotoSlide(s.SlideIndex)

        s.Shapes.Item(1).Select()
        aw.Selection.ShapeRange.TextFrame.TextRange.Select()
        aw.Selection.ShapeRange.TextFrame.TextRange.Characters(Start=1, Length=0).Select
        tr = aw.Selection.TextRange
        tr.Text = t1

        s.Shapes.Item(2).Select()
        aw.Selection.ShapeRange.TextFrame.TextRange.Select()
        if stype == ppLayoutText:
            aw.Selection.ShapeRange.TextFrame.TextRange.ParagraphFormat.Bullet.Visible = 0
        aw.Selection.ShapeRange.TextFrame.TextRange.Characters(Start=1, Length=0).Select
        tr = aw.Selection.TextRange
        tr.Text = t2
    slides.Range(slides.Count).Delete()
    pres.SaveAs(fname)

Edit:

Openoffice (that can export to powerpoint) also ships with it's scripting API that could be used to solve similar problems.

人│生佛魔见 2024-12-16 15:30:04

如果您需要的只是带有标题和项目符号文本的幻灯片,那么这很简单。创建一个如下所示的 txt 文件(使用 TAB 键代替下面的键):

Slide 1 Title
<tab>Bullet Level One Text
<tab><tab>Bullet Level Two Text
<tab>Back to Bullet Leven One again
Slide 2 Title
Slide 3 Title
<tab>More Bulleted text
<tab><tab>Tufte hates us by now
<tab><tab>But we don't care, do we?
Slide 4 Title

依此类推。保存文件,启动 PowerPoint,选择文件打开命令,在文件打开对话框中选择大纲或所有类型的文件,然后选择 TXT 文件。完毕。

If all you need is slides with titles and bulleted text, it's quite simple. Create a txt file that looks like this (use the TAB key in place of below):

Slide 1 Title
<tab>Bullet Level One Text
<tab><tab>Bullet Level Two Text
<tab>Back to Bullet Leven One again
Slide 2 Title
Slide 3 Title
<tab>More Bulleted text
<tab><tab>Tufte hates us by now
<tab><tab>But we don't care, do we?
Slide 4 Title

And so on. Save the file, start PowerPoint, choose the file open command, choose Outline or files of all types in the file open dialog box and select your TXT file. Done.

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