Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Thread Tools Display Modes
Old 03-18-2020, 02:29 PM
noslenwerd noslenwerd is offline PPTVBA: Item 9 not found in slides collection error. Windows 10 PPTVBA: Item 9 not found in slides collection error. Office 2016 for Mac
PPTVBA: Item 9 not found in slides collection error.
Join Date: Dec 2019
Posts: 15
noslenwerd is on a distinguished road
Question PPTVBA: Item 9 not found in slides collection error.

Getting the error below when trying to change text in a text box on my slideshow.

Essentially I am doing the following
  • Using excel to pull two things, a TITLE, and a TAG
  • I then open two powerpoints. pres1 is my master deck, pres2 is the deck that is created for each unique "case"
  • If the tag pulled from excel matches a slide name in pres1, it is copied into pres2
  • if that tag IS NOT found, I copy a template slide from pres1, add it to the end of the presentation (that works)
  • Last bit of business is to edit the text in that newly created slide to the string DSSTitle
  • See my comments below for where the error below pops up.

Any help would be appreciated

Option Explicit

Sub CreatePPTSlidesDrew()
Dim CustRow, CustCol, FinalCol, TitleRow As Long
Dim PPTLoc, TagName, TagRow, FileName, TempFileName, ReviewLoc, WebsiteURL, sSlideName, DSSTitle, SlideCount As String
Dim PPTApp As PowerPoint.Application
Dim pres1, pres2 As PowerPoint.Presentation
Dim oSl As Slide
Dim objSlide As Slide
Dim pp As Object
Dim objTextBox As Shape

    TempFileName = ThisWorkbook.Sheets("DSSWorksheet").Range("comp")

    Set pp = CreateObject("PowerPoint.Application")
    With ThisWorkbook.Sheets("ReviewContent")

        PPTLoc = "C:\ppt-test\SEE.pptm" 'PPT location
        On Error Resume Next 'If PPT is already running
            On Error GoTo 0 '~~ reset error handling
            Set pres1 = pp.Presentations.Open(FileName:=PPTLoc, ReadOnly:=False) 'Open Template
            Set pres2 = pp.Presentations.Add ' Create new file
            If pp.Version >= 9 Then
                'window must be visible
                pp.Visible = msoTrue
            End If
            CustRow = 17 'Row for review content for PPT files'
                    TagRow = CustRow - 1
                    TitleRow = CustRow - 3
                    FinalCol = .Cells(CustRow, .Columns.Count).End(xlToLeft).Column
                    For CustCol = 2 To FinalCol 'Move Through All Data
                        TagName = .Cells(TagRow, CustCol).Value 'Tag Name
                        DSSTitle = .Cells(TitleRow, CustCol).Value 'Title Name
                        ReviewLoc = .Cells(CustRow, CustCol).Value 'Review Location
                        On Error GoTo dss
                        If ReviewLoc Like "C*" Then
                            On Error Resume Next
                            Set oSl = pres1.Slides(TagName)
                                If Err.Number = 0 Then ' if no error, there's a slide by that name TagName in the main PPT Template
                                    pres2.Slides.Paste pres2.Slides.Count + 1
                                Else ' slide will be created in the main PPT template'
                                    pres1.Slides.Paste pres1.Slides.Count + 1
                                    SlideCount = pres1.Slides.Count
                                    MsgBox "Slide should have copied, and there are this many slides " & SlideCount 'This slide count does come back correctly
                                        On Error GoTo 0
                                        Set objSlide = pres1.Slides(SlideCount)
                                        objSlide.Name = TagName
                                        MsgBox "Slide renamed to '" + TagName + "'."
                                        Set objTextBox = objSlide.Shapes.Item(1)
                                        objTextBox.TextFrame.TextRange.Text = DSSTitle
                            End If
                        End If
                    Next CustCol
                    FileName = ThisWorkbook.Path & "\" & TempFileName & "-" & "PowerPoint" & Format(Now, "_mmddyyyy") & ".pptx"
                    pres2.SaveAs FileName 'This is where the new template is created
                    PPTApp.Visible = True 'Make the application visible to the user
     End With
End Sub
Reply With Quote

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Not Found Error ScottyBee Word VBA 2 04-16-2019 02:12 PM
PPTVBA: Item 9 not found in slides collection error. Error! Reference source not found - Why kennethc Word 3 06-15-2018 04:43 AM
Deleting item on multiple slides JM_Brazil PowerPoint 0 05-20-2017 04:37 PM
PPTVBA: Item 9 not found in slides collection error. Automatically remove a numbered item found in multiple places. Nathan8752 Word 1 10-20-2015 02:45 PM
"Unable to open *. The internet site reports that the item you requested could not be found." frayt Word 4 06-04-2015 06:11 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 05:55 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd. is not affiliated with Microsoft