Копия листа диаграммы и вставка в Power Point - PullRequest
0 голосов
/ 13 апреля 2020

Здравствуйте. Я пытаюсь скопировать и вставить множество листов диаграмм в PowerPoint, при этом каждый лист диаграммы имеет собственный слайд.

Этот код будет принимать диаграммы только на рабочих листах, а не на листах диаграмм.

Я нашел большую часть кода в сети и изменил его так, чтобы он вставлял диаграмму в виде изображения png в слайд. Как я могу изменить это так, чтобы я мог oop пройти через все листы диаграммы и заставить их перейти в Excel. Также я хотел бы начать с левого графика и l oop слева направо.

 Sub ExportChartsToPowerPoint_MultipleWorksheets()



    ' OVERVIEW:

    ' This script will loop through all the worksheets in the Active Workbook

    ' and copy all the Charts to a new PowerPoint presentation that we create.

    ' Each chart will get their own individual slide and will be placed in the center of it.



    'Declare PowerPoint Variables

    Dim PPTApp As PowerPoint.Application

    Dim pptPres As PowerPoint.Presentation

    Dim PPTSlide As PowerPoint.Slide

    Dim PPTShape As PowerPoint.Shape

    Dim SldIndex As Integer



    'Declare Excel Variables

    Dim Chrt As ChartObject
    Dim Chart As Chart
    Dim WrkSht As Worksheet


    'Create new PowerPoint Application & make it visible.

    Set PPTApp = New PowerPoint.Application

        PPTApp.Visible = True


    'Create new presentation in the PowerPoint application.

    Set pptPres = PPTApp.Presentations.Add


    'Create an index handler for slide creation.

    SldIndex = 1


    For Each WrkSht In Worksheets


        'Loop through all the CHARTOBJECTS in the ACTIVESHEET.

        For Each Chrt In WrkSht.ChartObjects



            'Copy the Chart

            Chrt.Copy


            'Create a new slide in the Presentation, set the layout to blank, and paste chart on to the newly added slide.

            Set PPTSlide = pptPres.Slides.Add(SldIndex, ppLayoutBlank)

                PPTSlide.Shapes.PasteSpecial DataType:=ppPastePNG



            'Increment index so that way we paste the next chart on the new slide that is added.

            SldIndex = SldIndex + 1



        Next Chrt


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