Hi, I'm running a code to Create PPT slides from my charts from Excel to PowerPoint -- but I get an error that reads "Run-time error '1004': Method 'Range' of object '_Global' failed. Here is the code:
Sub CreateSlide()
Dim ppApp As PowerPoint.Application
Dim ppSlide As PowerPoint.Slide
Dim SheetName As String
Dim PasteRange As Boolean
Dim RangeName As String
Dim RangeLink As Boolean
Dim AddSlidesToEnd As Boolean
'--------------------------------------------------------------------------------------
PasteRange = True
RangeName = "Print_Area"
RangeLink = True
AddSlidesToEnd = True
'--------------------------------------------------------------------------------------
'Create first PowerPoint Slide
If ppApp Is Nothing Then Set ppApp = New PowerPoint.Application
If ppApp.Presentations.Count = 0 Then ppApp.Presentations.Add
ppApp.Visible = True
'Add another PowerPoint Slide
If ppApp.ActivePresentation.Slides.Count = 0 Then
Set ppSlide = ppApp.ActivePresentation.Slides.Add(1, ppLayoutBlank)
Else
If AddSlidesToEnd Then
ppApp.ActivePresentation.Slides.Add ppApp.ActivePresentation.Slides.Count + 1, ppLayoutBlank
ppApp.ActiveWindow.View.GotoSlide ppApp.ActivePresentation.Slides.Count
Set ppSlide = ppApp.ActivePresentation.Slides(ppApp.ActivePresentation.Slides.Count)
Else
Set ppSlide = ppApp.ActiveWindow.View.Slide
End If
End If
'Add Excel WorkSheet data to PowerPoint Slide
If PasteRange = True Then
Here's the error-----> Range(RangeName).CopyPicture xlScreen, xlPicture
'To check PowerPoint version (PowerPoint 2000, 2003 or 2007).
If ppApp.Version > 10 Then
ppSlide.Shapes.PasteSpecial (ppPasteMetafilePicture)
Else
ppSlide.Shapes.Paste
End If
End If
With ppSlide.Shapes(1)
.Top = 20
.Left = 60
.Width = 570
End With
Application.CutCopyMode = False
End Sub
Help much appreciated!
Bookmarks