ネット上にある以下のマクロを入れて行ったところ
oFileStream.Open wavePath, SSFMCreateForWrite
の部分でひっかかっているようです。
「実行時エラー'5' プロシージャの呼び出し、または因数が不正です。」というエラーです。
Visual Basic 初心者のため、解決策をご存じの方よろしくお願いいたします。
使用したマクロ全体
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

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。