Excel VBA Code crashes PPT Presentation and leads to Error 462

Diskutiere Excel VBA Code crashes PPT Presentation and leads to Error 462 im Office Forum im Bereich Microsoft Community Fragen; Hallo, 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...
M

MSCom

Neuer Benutzer
Threadstarter
Dabei seit
20.09.2016
Beiträge
1
Hallo,


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: Link

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

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

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


 
Thema:

Excel VBA Code crashes PPT Presentation and leads to Error 462

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

  • EXCEL Sheet by VBA code printed as PDF - lines are missing in PDF file

    EXCEL Sheet by VBA code printed as PDF - lines are missing in PDF file: I have an created EXCEL sheet with many boxes. Each box represents an mechanical element. I fill the boxes according to the fault count of the...
  • Excel 365 VBA Code

    Excel 365 VBA Code: Hallo Zusammen, ich bitte um Eure Hilfe. Ich habe einen älteren VBA Code für den Füllstand von Kugelbehältern, siehe unten, der unter Excel 2013...
  • Excel Ausschneiden einer Textbox über VBA Code .PutInClipboard und Ausgabe in ein Word Dokument

    Excel Ausschneiden einer Textbox über VBA Code .PutInClipboard und Ausgabe in ein Word Dokument: Hallo, ich möchte gerne über einen VBA Code eine TextBox ausschneiden und den Inhalt in eine Zwischenablage speichern (.PutInClipboard)...
  • Excel VBA Code crashes PPT Presentation and lead to Error 462

    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...
  • Ähnliche Themen
  • EXCEL Sheet by VBA code printed as PDF - lines are missing in PDF file

    EXCEL Sheet by VBA code printed as PDF - lines are missing in PDF file: I have an created EXCEL sheet with many boxes. Each box represents an mechanical element. I fill the boxes according to the fault count of the...
  • Excel 365 VBA Code

    Excel 365 VBA Code: Hallo Zusammen, ich bitte um Eure Hilfe. Ich habe einen älteren VBA Code für den Füllstand von Kugelbehältern, siehe unten, der unter Excel 2013...
  • Excel Ausschneiden einer Textbox über VBA Code .PutInClipboard und Ausgabe in ein Word Dokument

    Excel Ausschneiden einer Textbox über VBA Code .PutInClipboard und Ausgabe in ein Word Dokument: Hallo, ich möchte gerne über einen VBA Code eine TextBox ausschneiden und den Inhalt in eine Zwischenablage speichern (.PutInClipboard)...
  • Excel VBA Code crashes PPT Presentation and lead to Error 462

    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...
  • Sucheingaben

    vba powerpoint crashes when reopening presentation

    ,

    vba error 462 when opening powerpoint presentation

    Oben