Hi!
I'm using the code below to copy paste some charts from an Excel file to a PowerPoint file. The macro is running from the Excel file. It works fine. I would like now to be able to adjust a little bit the plot area of the chart after it has been pasted on the powerpoint and not the whole size of the shape. In the code below I'm already adjusting the shape but all my attempts to adjust only the plot area failed.
Any help here, please?Sub CopyChartFromExcelToPpt() ' Turn screen updating off to speed up your macro code. You won't be able to see what the macro is doing, _ but it will run faster. Remember to set the ScreenUpdating property back to True when your macro ends. Application.ScreenUpdating = False Dim PPT_object As PowerPoint.Application Dim OpenPptDialogBox As Object Dim oCht As Chart Dim MyShape As Object Set PPT_object = CreateObject("PowerPoint.Application") Set OpenPptDialogBox = PPT_object.FileDialog(msoFileDialogOpen) ' Open the target PPT using dialog box: If OpenPptDialogBox.Show = -1 Then PPT_object.Presentations.Open (OpenPptDialogBox.SelectedItems(1)) End If ' Copy the chart from excel macro file ActiveSheet.ChartObjects("Chart 3").Copy ' Paste the chart in slide 4 of PPT Set MyShape = PPT_object.ActiveWindow.Presentation.Slides(4).Shapes.Paste ' Change the position of shape, its height and width With MyShape .Left = 17.25 .Top = 68.2307 .Height = 198.5074 .Width = 662.414897 End With ' Copy the chart from excel macro file ActiveSheet.ChartObjects("Chart 6").Copy ' Paste the chart in slide 4 of PPT Set MyShape = PPT_object.ActiveWindow.Presentation.Slides(4).Shapes.Paste ' Change the position of shape and its height and width With MyShape .Left = 17.25 .Top = 273.2619 .Height = 198.5074 .Width = 662.414897 End With ' Save and close the file PPT_object.ActivePresentation.Save Application.ScreenUpdating = True PPT_object.Windows(1).Close End Sub
Thanks in advance



Reply With Quote
