# Using VBA to paste chart into PowerPoint



## merce33 (Jan 5, 2007)

> Can anyone tell me why the following code is generating this error:
> 
> 
> > Run time error ‘-2147188160 (80048420)’:
> ...


----------



## TazRMan (Jan 5, 2007)

Look here.

http://www.mrexcel.com/board2/viewtopic.php?t=145036&highlight=chart+powerpoint


----------



## Jon Peltier (Jan 5, 2007)

This is redundant, you don't need two PowerPoint.Application object variables:


```
Set pptStart = CreateObject("PowerPoint.Application") 
    Set pptApp = GetObject(, "PowerPoint.Application")
```

use this instead:


```
On Error Resume Next
    ' Check whether PowerPoint is running
    Set PPApp = GetObject(, "PowerPoint.Application")
    If PPApp Is Nothing Then
        ' PowerPoint is not running, create new instance
        Set PPApp = CreateObject("PowerPoint.Application")
        PPApp.Visible = True
    End If
    On Error GoTo 0
```

your syntax is twisted:


```
pptPres.Slides.Paste pptPres.Slides.Count
```

should be


```
pptPres.Slides(pptPres.Slides.Count).Paste
```

or


```
pptPres.Slides(pptPres.Slides.Count).Shapes.Paste
```


----------

