目次
日本語版(ゆっくり)
Sub SlideVoice()
Dim i As Long
With ActivePresentation
For i = 1 To .Slides.Count
' 現在のスライドのノートを取得
Dim strNote As String
strNote = ActivePresentation.Slides(i).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text
' ノートが空白なら以下は実行しない
If strNote = "" Then
Else
' PowerPointファイルのあるフォルダパスを取得
Dim cd As String
cd = ActivePresentation.Path
' PowerPointファイルがあるのと同フォルダに、wavファイルを作成
Dim wavePath As String
wavePath = cd & "\voice.wav"
' wavファイルに保存
Const SAFT48kHz16BitStereo = 39
Const SSFMCreateForWrite = 3
Dim oFileStream, oVoice
Set oFileStream = CreateObject("SAPI.SpFileStream")
oFileStream.Format.Type = SAFT48kHz16BitStereo
oFileStream.Open wavePath, SSFMCreateForWrite
Set oVoice = CreateObject("SAPI.SpVoice")
' ここで再生速度を調整する
oVoice.Rate = -2
Set oVoice.AudioOutputStream = oFileStream
oVoice.Speak strNote
oFileStream.Close
' audioオブジェクトの埋め込み
Dim oSlide As Slide
Dim oShp As Shape
Set oSlide = ActivePresentation.Slides(i)
Set oShp = oSlide.Shapes.AddMediaObject2(wavePath, False, True, 10, 10)
With oShp.AnimationSettings.PlaySettings
.PlayOnEntry = True
.HideWhileNotPlaying = True
End With
' 埋め込み終わったらwavファイルを消す
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(wavePath) Then Kill wavePath
End If
Next i
End With
MsgBox "音声埋め込み完了"
End Sub
英語版(ゆっくり)
Sub SlideVoice()
Dim i As Long
With ActivePresentation
For i = 1 To .Slides.Count
' 現在のスライドのノートを取得
Dim strNote As String
strNote = ActivePresentation.Slides(i).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text
' ノートが空白なら以下は実行しない
If strNote = "" Then
Else
' PowerPointファイルのあるフォルダパスを取得
Dim cd As String
cd = ActivePresentation.Path
' PowerPointファイルがあるのと同フォルダに、wavファイルを作成
Dim wavePath As String
wavePath = cd & "\voice.wav"
' wavファイルに保存
Const SAFT48kHz16BitStereo = 39
Const SSFMCreateForWrite = 3
Dim oFileStream, oVoice
Set oFileStream = CreateObject("SAPI.SpFileStream")
oFileStream.Format.Type = SAFT48kHz16BitStereo
oFileStream.Open wavePath, SSFMCreateForWrite
Set oVoice = CreateObject("SAPI.SpVoice")
' ここで再生速度を調整する
oVoice.Rate = -2
' 英語の音声エンジンを設定
Set oVoice.Voice = oVoice.GetVoices("Language=409").Item(0)
Set oVoice.AudioOutputStream = oFileStream
oVoice.Speak strNote
oFileStream.Close
' audioオブジェクトの埋め込み
Dim oSlide As Slide
Dim oShp As Shape
Set oSlide = ActivePresentation.Slides(i)
Set oShp = oSlide.Shapes.AddMediaObject2(wavePath, False, True, 10, 10)
With oShp.AnimationSettings.PlaySettings
.PlayOnEntry = True
.HideWhileNotPlaying = True
End With
' 埋め込み終わったらwavファイルを消す
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(wavePath) Then Kill wavePath
End If
Next i
End With
MsgBox "音声埋め込み完了"
End Sub
日本語版
Sub SlideVoice()
Dim i As Long
With ActivePresentation
For i = 1 To .Slides.Count
' 現在のスライドのノートを取得
Dim strNote As String
strNote = ActivePresentation.Slides(i).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text
' ノートが空白なら以下は実行しない
If strNote = "" Then
Else
' PowerPointファイルのあるフォルダパスを取得
Dim cd As String
cd = ActivePresentation.Path
' PowerPointファイルがあるのと同フォルダに、wavファイルを作成
Dim wavePath As String
wavePath = cd & "\voice.wav"
' wavファイルに保存
Const SAFT48kHz16BitStereo = 39
Const SSFMCreateForWrite = 3
Dim oFileStream, oVoice
Set oFileStream = CreateObject("SAPI.SpFileStream")
oFileStream.Format.Type = SAFT48kHz16BitStereo
oFileStream.Open wavePath, SSFMCreateForWrite
Set oVoice = CreateObject("SAPI.SpVoice")
Set oVoice.AudioOutputStream = oFileStream
oVoice.Speak strNote
oFileStream.Close
' audioオブジェクトの埋め込み
Dim oSlide As Slide
Dim oShp As Shape
Set oSlide = ActivePresentation.Slides(i)
Set oShp = oSlide.Shapes.AddMediaObject2(wavePath, False, True, 10, 10)
With oShp.AnimationSettings.PlaySettings
.PlayOnEntry = True
.HideWhileNotPlaying = True
End With
' 埋め込み終わったらwavファイルを消す
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(wavePath) Then Kill wavePath
End If
Next i
End With
MsgBox "音声埋め込み完了"
End Sub
英語版
Sub SlideVoice()
Dim i As Long
With ActivePresentation
For i = 1 To .Slides.Count
' 現在のスライドのノートを取得
Dim strNote As String
strNote = ActivePresentation.Slides(i).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text
' ノートが空白なら以下は実行しない
If strNote = "" Then
Else
' PowerPointファイルのあるフォルダパスを取得
Dim cd As String
cd = ActivePresentation.Path
' PowerPointファイルがあるのと同フォルダに、wavファイルを作成
Dim wavePath As String
wavePath = cd & "\voice.wav"
' wavファイルに保存
Const SAFT48kHz16BitStereo = 39
Const SSFMCreateForWrite = 3
Dim oFileStream, oVoice
Set oFileStream = CreateObject("SAPI.SpFileStream")
oFileStream.Format.Type = SAFT48kHz16BitStereo
oFileStream.Open wavePath, SSFMCreateForWrite
Set oVoice = CreateObject("SAPI.SpVoice")
' 英語の音声エンジンを設定
Set oVoice.Voice = oVoice.GetVoices("Language=409").Item(0)
Set oVoice.AudioOutputStream = oFileStream
oVoice.Speak strNote
oFileStream.Close
' audioオブジェクトの埋め込み
Dim oSlide As Slide
Dim oShp As Shape
Set oSlide = ActivePresentation.Slides(i)
Set oShp = oSlide.Shapes.AddMediaObject2(wavePath, False, True, 10, 10)
With oShp.AnimationSettings.PlaySettings
.PlayOnEntry = True
.HideWhileNotPlaying = True
End With
' 埋め込み終わったらwavファイルを消す
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(wavePath) Then Kill wavePath
End If
Next i
End With
MsgBox "音声埋め込み完了"
End Sub