2016-06-17 10 views
0

1つのスライドを複数のpptプレゼンテーションにコピーするタスクがあります。すべてのpptは同じフォルダにあります。私は始める方法を知らない。これまでのところ、私はフォント、タイトルなどを変更するVBAで簡単なものをいくつか変更しました。誰でも私を助けることができますか? ありがとうございます1つのスライドを複数のプレゼンテーションにコピー

答えて

0

私はこのVBAコードを見つけました。これにより、ループを使用して、すべてのスライドが最初のプレゼンテーションから2番目のプレゼンテーションにコピーされます。ループを使用して、単一のスライドをコピーし、複数のプレゼンテーションにコピーするようにコードを変更することができます。例えば

Sub main() 
Dim objPresentation As Presentation 
Dim i As Integer 

'open the target presentation 
Set objPresentation = Presentations.Open("C:\2.pptx") 
For i = 1 To objPresentation.Slides.Count 
objPresentation.Slides.Item(i).Copy 
Presentations.Item(1).Slides.Paste 
Next i 
objPresentation.Close 
End Sub 

あなたがターゲットPPTXプレゼンテーションを開き、次のVBAマクロを実行する場合、それは2.pptxプレゼンテーションファイルのうち、最初のスライドをコピーして、現在のターゲットPPTXに貼り付けます。

Sub copySlide() 
Dim objPresentation As Presentation 

'open the target presentation 
'use path with the file if it is in a different location ("c:\2.pptx") 
Set objPresentation = Presentations.Open("2.pptx") 

'copy slide 1 from 2.pptx presentation 
'change the item number in order to target a different slide 
objPresentation.Slides.Item(1).Copy 

'paste the slide in target 
Presentations.Item(1).Slides.Paste 

objPresentation.Close 
End Sub 
0

この形態をとるInsertSlideFromFileメソッド使用:

.InsertFromFile(FileName, Index, SlideStart, SlideEnd) 

例。 test.pptxから4にスライド3をコピーして、現在開いているプレゼンテーション(ActivePresentationの)の最後にそれらを貼り付けるには:すべてのファイルを開いて、プレゼンテーションと同じパス上にある場合

' VBA macro to insert slide(s) from file 
' Written by Jamie Garroch of http://youpresent.co.uk/ 
Sub InsertSlides() 
    With ActivePresentation.Slides 
    .InsertFromFile "test.pptx", .Count, 3, 4 
    End With 
End Sub 

、あなたは自動化することができますこれで開始することによりパス:ここInsertSlideFromFile法上の

Dim myPath as String 
MyPath = ActivePresentation.Path 

さらに詳しい情報:

https://msdn.microsoft.com/en-us/library/office/ff746047.aspx?f=255&MSPPError=-2147217396

関連する問題