Results 1 to 3 of 3

Subscript out of range

Threaded View

  1. #1
    Registered User
    Join Date
    10-21-2021
    Location
    New Delhi
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Subscript out of range

    Hi All,

    I've written this code but getting Subscript out of range error. Any expert help please
    Sub Create_PPT()
    
    Dim ppt_app As New PowerPoint.Application
    Dim pre As PowerPoint.Presentation
    Dim slde As PowerPoint.slide
    Dim shp As PowerPoint.shape
    Dim wb As Workbook
    Dim rng As range
    
    Dim vSheet$
    Dim vRange$
    Dim vWidth As Double
    Dim vHeight As Double
    Dim vTop As Double
    Dim vLeft As Double
    Dim vSlide_No As Long
    Dim expRng As range
    
    Dim adminSh As Worksheet
    Dim configRng As range
    Dim xlfile$
    Dim pptfile$
    
    Application.DisplayAlerts = False
    
    Set adminSh = ThisWorkbook.Sheets("Data")
    Set configRng = adminSh.range("rng_sheet")
    
    xlfile = adminSh.[excelPth]
    pptfile = adminSh.[pptPath]
    
    Set wb = Workbooks.Open(xlfile)
    Set pre = ppt_app.Presentations.Open(pptfile)
    
    Set excelPth = adminSh.[excelPth]
    Set pptPath = adminSh.[pptPath]
    
    Set expRng = Sheets(vSheet$).range(vRange$) ''''GETTING ERROR ON THIS LINE''''
    Set slde = pre.Slides(vSlide_No)
    Set shp = slde.Shapes(1)
    
    wb.Activate
    
    For Each rng In configRng
        
        With ThisWorkbook.Sheets("Data")
        
        wb.Sheets(rng.Value).Activate
                    
        With adminSh
            vSheet$ = .Cells(rng.Row, 4).Value
            vRange$ = .Cells(rng.Row, 5).Value
            vWidth = .Cells(rng.Row, 6).Value
            vHeight = .Cells(rng.Row, 7).Value
            vTop = .Cells(rng.Row, 8).Value
            vLeft = .Cells(rng.Row, 9).Value
            vSlide_No = .Cells(rng.Row, 10).Value
        End With
        
        wb.Activate
        Sheets(vSheet$).Activate
        expRng.Copy
            
        slde.Shapes.PasteSpecial ppPasteBitmap
               
        With shp
            
            .Top = vTop
            .Left = vLeft
            .Width = vWidth
            .Height = vHeight
            
        End With
        
        Set shp = Nothing
        Set slde = Nothing
        
        Application.CutCopyMode = False
    
    End With
            
    Next rng
    
    pre.Save
    
    Set pre = Nothing
    Set ppt_app = Nothing
    Set expRng = Nothing
    wb.Close False
    Set wb = Nothing
    
    Application.DisplayAlerts = True
    
    
    End Sub
    Last edited by Praveenlal; 03-23-2022 at 02:25 PM. Reason: changed code

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 07-11-2019, 05:36 AM
  2. [SOLVED] VBA compile error on simple copy-paste special
    By DJDRU in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2017, 12:42 PM
  3. VBA to copy Excel data range and paste in PowerPoint text boxes
    By palaniappan0212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2016, 04:43 AM
  4. Copy/Paste excel data with data bars to Powerpoint
    By sgoyal in forum Excel General
    Replies: 1
    Last Post: 03-05-2014, 04:18 PM
  5. Replies: 4
    Last Post: 02-01-2013, 12:00 PM
  6. Compile error adding picture to powerpoint?
    By nickypatterson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-31-2011, 02:08 PM
  7. Compile error in copy/paste code
    By carbonboywonder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2010, 07:46 AM

Tags for this Thread

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