PowerPoint VBA для сохранения исходного форматирования в целевом PowerPoint - PullRequest
0 голосов
/ 25 апреля 2020

У меня есть следующий код для копирования указанных c слайдов (на основе тегов) в новую презентацию. Я хочу сохранить форматирование исходной презентации в скопированных слайдах целевой презентации.

Текущий код:

Option Explicit
Private Sub CommandButton1_Click()

Dim strTagName As String
Dim strTagValue As String

strTagName = "pname"
strTagValue = "Azure"

Dim currentPresentation As Presentation
Dim newPresentation As Presentation
Dim s As Slide

' Save reference to current presentation
Set currentPresentation = Application.ActivePresentation

' Save reference to current slide
'Set currentSlide = Application.ActiveWindow.View.Slide

' Add new Presentation and save to a reference
Set newPresentation = Application.Presentations.Add

For Each s In currentPresentation.Slides
    If s.Tags(strTagName) = "Azure" Then

    s.Copy
    newPresentation.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")

    End If

Next

newPresentation.SaveAs (currentPresentation.Path & "\" & strTagValue & "_Quals Slides.pptx")

End Sub

1 Ответ

0 голосов
/ 26 апреля 2020
Option Explicit
Private Sub CommandButton1_Click()

Dim strTagName As String
Dim strTagValue As String

strTagName = "pname"
strTagValue = "Azure"

Dim currentPresentation As Presentation
Dim newPresentation As Presentation
Dim s As Slide

' Save reference to current presentation
Set currentPresentation = Application.ActivePresentation

' Save reference to current slide
' Set currentSlide = Application.ActiveWindow.View.Slide

' Add new Presentation and save to a reference
Set newPresentation = Application.Presentations.Add

For Each s In currentPresentation.Slides
    If s.Tags(strTagName) = "Azure" Then

    s.Copy
    newPresentation.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
    For i = 1 To 5000: DoEvents: Next

    End If

Next

newPresentation.SaveAs (currentPresentation.Path & "\" & strTagValue & "_Quals Slides.pptx")

End Sub
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...