I want to paste an Excel graph with "Keep original formatting" in PowerPoint.
However, if you execute it, it will be pasted as a figure.
I would like to know the cause and how to deal with it.
Launch Sub PowerPoint () Dim ppApp As New PowerPoint.Application Dim ppPt As Presentation Dim ppSlide As Slide Dim ppShape As PowerPoint.Shape Dim ws As Worksheet Dim test_st As String Dim i As Long Dim x As Long Dim ppPrs As Presentation Set ppPrs = ppApp.Presentations.Open (ThisWorkbook.Path&"\ graph @ .pptx") Set ws = ThisWorkbook.Worksheets ("A_01") 'Paste graph 'CPU For i = 1 To 18 ws.ChartObjects ("Chart"&i) .Chart.CopyPicture 'Copy chart as picture ppPrs.Slides (i) .Shapes.PasteSpecial DataType: = ppPasteEnhancedMetafile, Link: = msoFalse 'Paste with PowerPoint command If ppApp.ActiveWindow.Selection.Type = ppSelectionNone Or ppApp.ActiveWindow.Selection.Type = ppSelectionSlides Then Exit Sub End If For Each ppShape In ppApp.ActiveWindow.Selection.ShapeRange ppShape.LockAspectRatio = msoFalse ppShape.Left = Application.CentimetersToPoints (0.8) ppShape.Top = Application.CentimetersToPoints (3.7) ppShape.Width = Application.CentimetersToPoints (11.875) ppShape.Height = Application.CentimetersToPoints (4.6) Next ppShape Next i End Sub
Answer # 1
ws.ChartObjects ("Chart"&i) .Chart.CopyPicture 'Copy chart as picture
And since the graph is copied as an image, the pasted image is also an image.
Answer # 2
When I looked into it, PowerPoint PasteSpecial's DataType doesn't have "Keep original format", so it seems that there is no choice but to execute the command with ExecuteMso.
See the comment section below the reference URL
Here is the code copy of the above URL. (By Takapi-san)
* Since ExecuteMso is asynchronous execution, the point is to wait until the graph pasting is completed.
'Get the number of sheets before pasting shc = ppSld.Shapes.Count 'pasting ppApp.CommandBars.ExecuteMso "PasteExcelChartSourceFormatting" 'Wait until the number before pasting changes Do While shc = ppSld.Shapes.Count DoEvents Loop
Answer # 3
Copy as an image and
Even when pasting with
ppPrs.Slides (i) .Shapes.PasteSpecial DataType: = ppPasteEnhancedMetafile,
, it is pasted in an image format called "EnhancedMetafile", so it seems that it is necessary to get this too. I don't have the time to make a similar one and try it out.
- vba paste will be overwritten
- copy paste in vba does not work well (performed multiple times)
- [vba] i want to paste the copied data to the next column after the last column of another sheet
- vba - copy selection and paste to another file
- i want to paste the second data under the last row of the first data when combining the workbooks in a folder with excelvba
- vba - excel i want to copy and paste something other than a specific column
- vba conditional copy and paste
- vba - this is a question about the efficiency of copy and paste
- cannot paste only values with vba (between the same book and multiple sheets)
- [vba] paste csv and total with worksheet function
- i want to read excel file with vba macro of powerpoint for mac 2016
- vba browser operation chrome copy and paste
- vba - excel macro excel2016 graph drawing before msgbox display does not work
- [vba macro] i want to copy and paste cells that match in multiple searches
- vba - copy and paste conditional formatting or ctrl + c:ctrl + v does not transfer to other cells
- vba - i want to paste an image into a specified cell
- how can i copy and paste to a different sheet without activating the vba page?
- vba - copy and paste with excel macro
- vba - i want to paste multiple images to the specified destination
- vba - end of vbs powerpoint slideshow
- python - how to know the arguments of a vba function in a protected excel file
- vba - i want to transfer to a cell that meets two conditions
- vba error occurs after the second time
- vba sheet 1 a7, c7, sheet 2 a2 "2020" 03 "01" numerical value is added and displayed in the cell as "20
- the process is interrupted when i click the button on the web page with vba
- vba - i want to copy the last line and paste it to the last line +1
- vba - using the entirerow property
- vba - i want to divide the sheet by the same data
- about excel vba loop
- vba - how to apply change events to multiple cells at the same time