+ Reply to Thread
Results 1 to 3 of 3

Excel Powerpoint Automation Run time Error

  1. #1
    Registered User
    Join Date
    03-31-2011
    Location
    South africa,johannesburg
    MS-Off Ver
    Excel 2007
    Posts
    2

    Excel Powerpoint Automation Run time Error

    Hi All
    I'm new to VBA, can you please assist.

    I get the following error :

    Run-time error'-2147467259 (80004005)';

    Powerpoint could not open the file.



    Please see below code used:


    Private Const PivotChangeFieldName = "CODE"
    Dim Path As String

    Private Sub UpdatePivots()
    Dim Pt As PivotTable
    Dim Ws As Worksheet
    Dim Field As PivotField
    Dim Dealer As String

    Dealer = Worksheets("Macro").Range("H6").Value

    For Each Ws In ThisWorkbook.Worksheets
    For Each Pt In Ws.PivotTables
    If InStr(1, UCase(Pt.Name), "ALL") = 0 Then
    With Ws.PivotTables(Pt.Name).PivotFields(PivotChangeFieldName)
    .EnableMultiplePageItems = False

    On Error Resume Next
    .CurrentPage = Dealer
    'If Err <> 0 Then
    ' Exit Sub 'Exit the loop if item doesnt exist
    'End If
    On Error GoTo 0
    'Test if the item in the pivot table exists, if not, cancel

    End With 'Change the filter
    End If

    Next Pt 'Loop all pivots in the sheet
    Next Ws 'loop all sheets
    End Sub

    Private Sub Update_PowerPoint_Presentation()
    'Opens a PowerPoint Document from Excel
    Dim objPPT As Object
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    objPPT.Presentations.Open Path & "\Analysis.pptm"

    'Update Link and Save Document to another name'
    On Error GoTo 0
    objPPT.ActivePresentation.UpdateLinks
    objPPT.ActivePresentation.SaveAs Path & "\Output\" & Sheets("book1").Range("D43").Value & ".pdf", FileFormat:=ppSaveAsPDF
    objPPT.Quit
    Set objPPT = Nothing
    End Sub


    Public Sub Run_Reports()
    Dim Count, Total As Double
    Dim TimeBegin As Date

    Total = CDbl(Sheets("Dealer Report Run").Range("G1").Value)
    TimeBegin = Now()

    Path = ThisWorkbook.Path

    Application.StatusBar = "0.00%: Initiating"
    Application.ScreenUpdating = False

    For Count = 1094 To Total
    Sheets("Macro").Range("H6").Value = Sheets("Report Run").Cells(Count + 1, 1).Value

    Application.StatusBar = Round((Count / Total) * 100, 2) & "%: Updating Pivot (" & Count & " of " & Total & ") Estimated Time Remaining: " & Format(((Now() - TimeBegin) / Count) * (Total - Count), "HH:MM:SS") & "."
    UpdatePivots

    Application.StatusBar = Round((Count / Total) * 100, 2) & "%: Creating Presentation (" & Count & " of " & Total & ") Estimated Time Remaining: " & Format(((Now() - TimeBegin) / Count) * (Total - Count), "HH:MM:SS") & "."
    Update_PowerPoint_Presentation

    'If Count = 10 Then Exit For 'Only produce X reports

    If (Count / 10) = Round(Count / 10, 0) Then DoEvents 'Update the screen if stopped updating
    Next

    Application.ScreenUpdating = True

    Application.StatusBar = "Complete"

    End Sub



    Error normally errors at line :
    objPPT.ActivePresentation.SaveAs Path & "\Output\" & Sheets("book1").Range("D43").Value & ".pdf", FileFormat:=ppSaveAsPDF


    Does anyone know how to resolve this error.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Excel Powerpoint Automation Run time Error

    Welcome to the forum.

    We'd like to help you but first..

    Pls take some minutes to read forum rules and specially-in this case- rule#3 and add code tags around your code.
    Then anyone will be able to help you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    03-31-2011
    Location
    South africa,johannesburg
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Excel Powerpoint Automation Run time Error

    Hi All
    Something I forgot to mention, This code works, Runs for a few 100 iterations , then I get the error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Facing 'run-time error -2147217871 (80040e31) Automation error' in excel VBA
    By junaidanjum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2013, 03:48 AM
  2. Replies: 7
    Last Post: 05-15-2013, 09:02 AM
  3. [SOLVED] Run-time error '-2147217900(80040e14)': Automation error
    By Lloyd Blankfein in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2012, 06:54 AM
  4. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  5. Run-time error '-2147417848 (80010108)': Automation error
    By Lightboxes in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2012, 05:53 PM

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