如何解决如何生成带有幻灯片时间和标题的Powerpoint视频制作的YouTube索引?
我需要制作一个很长的视频教程,并且YouTube具有一个很棒的功能,即视频的描述会在每行开头自动针对hh:mm:ss进行解析,以使观看者可以转到视频中的特定时间。有没有一种方法可以自动使用VBA和powerpoint的对象模型来生成带有幻灯片标题的计时?
解决方法
以下脚本似乎可以完成任务。关于如何在Powerpoint中运行VBA的最清晰的说明是在https://www.rdpslides.com/pptfaq/FAQ00033_How_do_I_use_VBA_code_in_PowerPoint.htm。它基于https://www.rdpslides.com/pptfaq/FAQ00413_Show_me_the_transition_time_of_each_slide_and_total_running_time_of_the_show.htm
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
示例输出如下:
00:00:00 1 Title
00:00:56 2 heading slide 2
00:01:57 3 Your heading slide 3
我在YouTube描述中做出的最终计时是在https://youtu.be/FP01jPau5dM。
我无法完成的一件事是格式化总时间。我的VBA Format((lngTotalTime),“ hh:mm:ss”)总是在00:00:00出来。这就是为什么在代码中将时间手动转换为hh mm和ss的原因。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。