2017-08-03 25 views
-1

特定のスライドを作成するマクロを呼び出してPowerPointプレゼンテーションを作成するスクリプトがあります。しかし、プレゼンテーションの一部については、最後のプレゼンテーションからスライドをつかんで新しいプレゼンテーションにコピーする必要があります。しかし、プレゼンテーションを開くとエラーが表示されます。オブジェクトプレゼンテーションの「開く」メソッドが失敗しました。どうすれば修正できますか?VBAでPowerPointエラーが発生する

Sub CreateNewPresentation() 

    Dim ppApp As PowerPoint.Application 
    Dim ppPres As PowerPoint.Presentation 
    Dim slidesCount As Long 

    On Error Resume Next 
    Set ppApp = GetObject(, "PowerPoint.Application") 
    On Error GoTo 0 

    If ppApp Is Nothing Then 
    Set ppApp = New PowerPoint.Application 
    End If 

    Set ppPres = ppApp.Presentations.Add 
    ppApp.Visible = True 
    slidesCount = ppPres.Slides.Count 
    Call create_Views_Slide(slidesCount, ppPres, ppApp) 
End sub 

sub create_Views_Slide(sldNum As Long, ppPrez As PowerPoint.Presentation, ppt As PowerPoint.Application) 
    Dim myFilePath As String, myFileName As String, myFile As String 
    Dim ppSlide As PowerPoint.Slide 
    Dim objPres As PowerPoint.Presentation 
    Set ppSlide = ppPrez.Slides.Add(sldNum + 1, ppLayoutBlank) 
    ppPrez.PageSetup.SlideSize = ppSlideSizeLetterPaper 
    myFile="File path....." 
    Set objPres = ppt.Presentations.Open(myFile) 
    objPres.Slides(1).Copy 
    ppPrez.Slides.Paste Index:=1 
    objPres.Close 

End Sub 
(OPに代わって投稿)

答えて

1

ファイルパスの文字列が間違っていました。

関連する問題