粘贴选定Excel嵌入式图表到当前PowerPoint幻灯片中
01 |
Sub CopyChartsIntoPowerPoint() |
05 |
Dim pptApp As PowerPoint.Application |
06 |
Dim iShapeIx As Integer , iShapeCt As Integer |
07 |
Dim myShape As Shape, myChart As ChartObject |
08 |
Dim bCopied As Boolean |
10 |
Set pptApp = GetObject(, "PowerPoint.Application" ) |
12 |
If ActiveChart Is Nothing Then |
15 |
iShapeCt = Selection.ShapeRange.count |
17 |
MsgBox "Select charts and try again" , vbCritical, "Nothing Selected" |
21 |
For Each myShape In Selection.ShapeRange |
24 |
Set myChart = ActiveSheet.ChartObjects(myShape.name) |
26 |
bCopied = CopyChartToPowerPoint(pptApp, myChart) |
32 |
Set myChart = ActiveChart.Parent |
33 |
bCopied = CopyChartToPowerPoint(pptApp, myChart) |
36 |
Dim myPptShape As PowerPoint.Shape |
38 |
Dim iShapesCt As Integer |
42 |
iShapesCt = pptApp.ActiveWindow.Selection.SlideRange.Shapes.count |
44 |
MsgBox "There are no shapes on the active slide" , vbCritical, "No Shapes" |
50 |
myScale = InputBox(Prompt:= "Enter a scaling factor for the shapes (percent)" , _ |
51 |
Title:= "Enter Scaling Percentage" ) / 100 |
54 |
For Each myPptShape In pptApp.ActiveWindow.Selection.SlideRange.Shapes |
55 |
If myPptShape.name Like "Picture*" Then |
57 |
.ScaleWidth myScale, msoTrue, msoScaleFromMiddle |
58 |
.ScaleHeight myScale, msoTrue, msoScaleFromMiddle |
65 |
Set myPptShape = Nothing |
69 |
Function CopyChartToPowerPoint(oPPtApp As PowerPoint.Application, _ |
70 |
oChart As ChartObject) |
71 |
CopyChartToPowerPoint = False |
73 |
oChart.Chart.CopyPicture Appearance:=xlScreen, Format:=xlPicture, Size:=xlScreen |
74 |
oPPtApp.ActiveWindow.View.Paste |
76 |
CopyChartToPowerPoint = True |
|