Excel VBA Code crashes PPT Presentation and lead to Error 462

Diskutiere Excel VBA Code crashes PPT Presentation and lead to Error 462 im Office Forum im Bereich Microsoft Community Fragen; Hallo, you guys are my lost hope. Nobody and nothing was able to help me so far, not google, not Stackoverflow, no other experts. I ...


+ Antworten + Neues Thema erstellen
Ergebnis 1 bis 1 von 1
  1. #1

    Excel VBA Code crashes PPT Presentation and lead to Error 462

    Hallo,

    you guys are my lost hope. Nobody and nothing was able to help me so far, not google, not Stackoverflow, no other experts.

    I have a Code, which starts in Excel and opens a PPT, updates the links, renames the PPT and closes it. The problem: Sometimes (not always) the PPT Presentation crashes and my code stops running, resulting in the following error message: "Error 462 the remote server machine does not exist or is unavailable"


    The PPT seems to crash in different parts of the code but mostly at "Set PP = pptApp.Presentations.Open(pptVorlage)". Sometimes the code works fine for 50 loops, sometimes crashes after the first one.

    Link to the files: https://drive.google.com/open?id=1D3...e1QJtApFgS2WDT

    Please help me, it has already cost me days :/

    Kind regards and thanks in advance for your help
    Michael

    Code:


    Option Explicit
    Public myfilename As String


    Sub Saveas_PPT_and_PDF()

    Set ws_company = Tabelle2

    Dim PP As PowerPoint.Presentation
    Dim sh As Variant
    Dim company As String
    Dim strPOTX As String
    Dim strPfad As String
    Dim pptVorlage As String
    Dim newpath As String
    Dim newpathpdf As String
    Dim Cell As Range
    Dim pptApp As Object

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    pptVorlage = "C:\Users\Michael\Desktop\Test PPT\MSO Tester.pptx"

    company = Dropdown.ws_company.Range("C2").Value

    Set pptApp = CreateObject("PowerPoint.Application")

    Dim drop As Range
    Set drop = ws_company.Range(ws_company.Cells(5, 3), ws_company.Cells(Rows.Count, 3).End(xlUp)).SpecialCells(xlCellTypeVisible)

    For Each Cell In drop

    ws_company.Range("C2").Value = Cell.Value


    'Set PP = Nothing
    Set PP = pptApp.Presentations.Open(pptVorlage)'often I get the error message here, so it must crash before this part, correct?

    newpath = Replace(pptVorlage, "MSO", "" & Cell & "MSO")


    'Application.Wait (Now + TimeValue("0:00:05"))
    PP.UpdateLinks
    PP.SaveAs newpath

    newpathpdf = Replace(newpath, "pptx", "pdf")

    PP.ExportAsFixedFormat "" & newpathpdf & "", ppFixedFormatTypePDF, ppFixedFormatIntentPrint

    'pptApp.Presentations(newpath).Close
    PP.Close

    Set PP = Nothing
    Next

    'this part below closes PPT application if there are no other presentation object open. If there is at least 1, it leaves it open

    If IsAppRunning("PowerPoint.Application") Then
    If pptApp.Windows.Count = 0 Then

    pptApp.Quit
    End If
    End If
    Set pptApp = Nothing
    Set PP = Nothing
    Call RefreshDataEachHour

    End Sub




    Function IsAppRunning(ByVal sAppName) As Boolean
    Dim oApp As Object
    'On Error Resume Next
    Set oApp = GetObject(, sAppName)
    If Not oApp Is Nothing Then
    Set oApp = Nothing
    IsAppRunning = True
    Else
    IsAppRunning = False
    End If
    End Function



    Public Sub RefreshDataEachtenseconds()

    Application.OnTime Now + TimeValue("00:00:10"), "Saveas_PPT_and_PDF"

    End Sub

  2. Schau dir mal diesen Ratgeber an. Dort wird jeder fündig!

    Registrieren bzw. einloggen, um diese und auch andere Anzeigen zu deaktivieren

Excel VBA Code crashes PPT Presentation and lead to Error 462

Excel VBA Code crashes PPT Presentation and lead to Error 462 - Ähnliche Themen


  1. Office 365 installation kept on getting an error saying error code: 0-1007 (0): Hi, I kept getting this particular error code: 0-1007 (0).I have disabled my firewall and antivirus. Kept on if my internet is connected and it is...



  2. Excel VBA - Einzelschritt F8 führt Code komplett aus: Hallo zusammen, beim Debugen meines Codes in VBA passiet es, dass ich an einer bestimmten Stelle keinen Einzelschritt (F8) machen kann. Ab der...



  3. Excel CSV import via VBA - out of memory error: Hello, since beginning of December, I'm experiencing problems with VBA based combined HTML/CSV import to an Excel 2016 workbook. The code imports...



  4. Excel crashes after Application Wait: After this Auto_open () makro ist stopped by hitting the ESC Key, it is not possible to edit the makro an save the worksheet manualy after stopping...



  5. VBA Code Zeilenumbruch: Hallo, ich sehe den Fehler im Code nicht. Nachdem ich versucht habe einen Zeilenumbruch einzuehren geht es nicht mehr... LG Co...