gpt4 book ai didi

vba - 如何为带有幻灯片时间和标题的PowerPoint视频制作生成YouTube索引?

转载 作者:行者123 更新时间:2023-12-03 05:52:41 25 4
gpt4 key购买 nike

我需要制作一部很长的视频教程,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格式((lngTotalTime),“hh:mm:ss”)总是在00:00:00出来。这就是为什么在代码中将时间手动转换为hh mm和ss的原因。

关于vba - 如何为带有幻灯片时间和标题的PowerPoint视频制作生成YouTube索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63611333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com