Results 1 to 15 of 15

Method 'Open' of object 'Presentations' failed when running a VBA loop

Threaded View

  1. #1
    Registered User
    Join Date
    06-20-2016
    Location
    Sweden
    MS-Off Ver
    Windows 7
    Posts
    13

    Method 'Open' of object 'Presentations' failed when running a VBA loop

    Hello Excel Gurus,

    This is the first time I am trying to make a VBA macro which generates PDF presentations automatically, so I am a newbie to this. It works to run once, but I get an error message when the macro runs a second time in a loop.

    I get the following two error messages:
    - Method 'Open' of object 'Presentations' failed
    - The remote server machine does not exist or is unavailable (run-time error '462')

    I have Googled around a bit to figure out what the issue is, but not found a solution which I fully understand, i.e. I still do not know what is missing in my code.

    I am using the below code:

    PHP Code: 
    Sub generateReport()
          
        
    Dim PPT As PowerPoint.Application
        Set PPT 
    = New PowerPoint.Application
        PPT
    .Visible True
        
        Dim objReport 
    As Presentation
        Dim objSlide 
    As Slide
        Dim objShape 
    As Object
         
        excelPath 
    Application.ActiveWorkbook.Path
        pptTemplateName 
    "Report.pptx"
        
        'THIS IS WHERE THE ERROR APPEARS IN THE SECOND LOOP'
        
    Set objReport PPT.Presentations.Open(Filename:=excelPath "\" & pptTemplateName)    
        
        'Defining presentation version'
        versionNumber = Sheets("
    Analysis").Range("D4").Value 

        'Inputting text to presentation from Excel'
        Dim i As Integer
        
        firstInputRow = 38
        inputLength = Sheets("
    Analysis").Range("D" & firstInputRow - 3).Value
        
        For i = 1 To inputLength
        
            slideNum = Sheets("
    Analysis").Range("B" & firstInputRow + i - 1).Value
            boxName = Sheets("
    Analysis").Range("C" & firstInputRow + i - 1).Value
            textInput = Sheets("
    Analysis").Range("D" & firstInputRow + i - 1).Value
          
            Set objSlide = objReport.Slides(slideNum)
            objSlide.Shapes(boxName).TextFrame.TextRange.Text = textInput
      
        Next i

        'Updating charts in presentation'
        inputLength = Sheets("
    Analysis").Range("J" & firstInputRow - 3).Value
          
        For i = 1 To inputLength
        
            slideNum = Sheets("
    Analysis").Range("I" & firstInputRow + i - 1).Value
            boxName = Sheets("
    Analysis").Range("J" & firstInputRow + i - 1).Value
            objReport.Slides(slideNum).Shapes(boxName).LinkFormat.Update
          
        Next i
        
        'Saving presentation as PDF'
        FileName2 = Replace(excelPath & "
    \" & versionNumber & " " & pptTemplateName, "pptx", "pdf")
        
        objReport.SaveAs FileName2, ppSaveAsPDF
        objReport.Close

        Set objShape = Nothing
        Set objSlide = Nothing
        Set objReport = Nothing
        
        PPT.Quit
        Set PPT = Nothing
        
    End Sub 

    Any help would be greatly appreciated.
    Last edited by apantorsk; 06-20-2016 at 09:08 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Method 'Open of object 'Workbooks'Failed
    By elmnas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2015, 07:40 PM
  2. [SOLVED] method 'open text' of object 'workbooks' failed
    By tina in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-23-2013, 11:53 AM
  3. method 'open text' of object 'workbooks' failed
    By richieniel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2013, 10:42 AM
  4. [SOLVED] Method 'open' of object 'workbooks' failed
    By crunchKH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 09:13 PM
  5. [SOLVED] Method 'Range' of object '_Global' failed error message on running userform when another
    By sivakumar123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-01-2012, 11:39 AM
  6. Open method of object failed error
    By maw230 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2011, 09:19 AM
  7. Method 'Open' of object 'Workbooks' failed from within browser window
    By ramiro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2008, 12:08 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