首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用幻灯片计时和标题为powerpoint视频制作生成YouTube索引?

如何使用幻灯片计时和标题为powerpoint视频制作生成YouTube索引?
EN

Stack Overflow用户
提问于 2020-08-27 15:40:32
回答 1查看 23关注 0票数 0

我需要制作一个很长的视频教程,YouTube有一个伟大的功能,视频描述是自动解析的hh:mm:ss在行的开头,以允许观众转到视频中的特定时间。有没有办法自动使用VBA和powerpoint的对象模型来生成带有幻灯片标题的计时?

EN

回答 1

Stack Overflow用户

发布于 2020-08-27 15:40:32

下面的脚本似乎可以完成这项工作。我在https://www.rdpslides.com/pptfaq/FAQ00033_How_do_I_use_VBA_code_in_PowerPoint.htm上找到了关于如何在powerpoint中运行VBA的最清晰的说明。它是基于https://www.rdpslides.com/pptfaq/FAQ00413_Show_me_the_transition_time_of_each_slide_and_total_running_time_of_the_show.htm

代码语言:javascript
运行
复制
Sub PowerPointYouTubeTiming()
' Copyright/Last Edited 11 December, 2019 by Stepen Rindsberg dba PPTools
' Modified by T Delbruck for powerpoint youtube timing 26.8.2020

Dim oSld As Slide
Dim strMessage As String
Dim lngTotalTime As Long


lngTotalTime = 0
' Use this to collect times for ALL slides:
For Each oSld In ActivePresentation.Slides
' Or comment it out and uncomment this to get just the selected slides:
' For Each oSld in ActiveWindow.Selection.SlideRange
    strMessage = strMessage _
        & Format(lngTotalTime \ 3600, "00") & ":" & Format((lngTotalTime Mod 3600) \ 60, "00") & ":" & Format(lngTotalTime Mod 60, "00") _
        & vbTab _
        & CStr(oSld.SlideNumber) _
        & vbTab
    If oSld.Shapes.HasTitle Then
        strMessage = strMessage _
            & oSld.Shapes.Title.TextFrame.TextRange.Text & vbCrLf
    Else
        strMessage = strMessage & vbCrLf
    End If
    lngTotalTime = lngTotalTime + oSld.SlideShowTransition.AdvanceTime
    
Next oSld

' Comment these out if you don't want to see them
' MsgBox strMessage
' MsgBox ("Total time: " & CStr(lngTotalTime))

' And if you want to write the results to a text file:
Dim FileNum As Integer
Dim FileName As String

' Edit this to suit, especially if you use a Mac:
' As written, it'll pick up your TEMP folder location automatically:
FileName = Environ$("TEMP") & "\" & "YouTubeTimings.txt"

FileNum = FreeFile()
Open FileName For Output As FileNum
Print #FileNum, strMessage
' Print #FileNum, "Total time: " & Format((lngTotalTime), "hh:mm:ss")
Close #FileNum
' view the file in notepad
Call Shell("Notepad.exe " & FileName, vbNormalFocus)
' or if you use a mac, comment that out and open the file in any text editor you like

End Sub

示例输出如下所示:

代码语言:javascript
运行
复制
00:00:00    1   Title
00:00:56    2   heading slide 2
00:01:57    3   Your heading slide 3

我在https://youtu.be/FP01jPau5dM做的YouTube描述中的计时结果。

有一件事我做不到,那就是总时间的格式化。我的VBA格式((LngTotalTime),"hh:mm:ss")总是在00:00:00出现。这就是在代码中手动将时间转换为hh、mm和ss的原因。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63611333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档