+ Reply to Thread
Results 1 to 2 of 2

Run0time error '1004': Method 'Range' of object '_Global' failed

Hybrid View

  1. #1
    Registered User
    Join Date
    08-12-2011
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    2

    Run0time error '1004': Method 'Range' of object '_Global' failed

    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!
    Last edited by JosephP; 09-28-2012 at 09:13 AM. Reason: add code tags

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Run0time error '1004': Method 'Range' of object '_Global' failed

    hi and welcome to the forum :-)

    where is this code run from specifically? I assume it's in excel but is it in a worksheet module or normal module or other?

    also please note that I added code tags to your post in accordance with forum rule 3-please use them when posting code in future. thanks
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1