Close Powerpoint Object Using Excel VBA (Not Using Powerpoint.Application)

Hope someone can help me with VBA code. I use a VBA loop to insert Excel charts, text fields and tables into a Powerpoint template. However, since I cannot be sure that the user will have the Powerpoint object library installed, I cannot use Dim PPTApp as a syntax like Powerpoint.Application.

I use objects. It works great. Except for one part: closing Powerpoint.

the code:

Dim oPPTPres As Object  ' Late binding: This is a PowerPoint.Presentation but we cannot assume that the Microsoft PowerPoint 11 library will be loaded in the workbook that this module has been copied to.
Dim oPPTShape As Object ' Late binding: This is a PowerPoint.Shapebut we cannot assume that the Microsoft PowerPoint 11 library will be loaded in the workbook that this module has been copied to.


PPTFile = Range("PPTFile").value ' Read PowerPoint template file name
Set oPPTPres = GetObject(PPTFile): oPPTPres.Application.Visible = msoTrue ' Switch to or open template file

. ,,.

strNewPresPath = Range("OutputFileName").value
oPPTPres.SaveAs strNewPresPath
' Range("PPTFile").value = strNewPresPath
ScreenUpdating = True
oPPTPres.Close 'Closes presentation but not Powerpoint
oPPTPres.Application.Quit 'No noticeable effect

, Powerpoint ( ). , , ( , ), , Powerpoint, .

?

!

+5
4

, . oPPTPres = Nothing, , . PowerPoint .

Dim oPPTPres As Object  ' Late binding: This is a PowerPoint.Presentation but we cannot assume that the Microsoft PowerPoint 11 library will be loaded in the workbook that this module has been copied to.
Dim oPPTShape As Object ' Late binding: This is a PowerPoint.Shapebut we cannot assume that the Microsoft PowerPoint 11 library will be loaded in the workbook that this module has been copied to.
Dim oPPTApp As Object

Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = True

Set oPPTPres = oPPTApp.Presentations.Open(PPTFile)

...

oPPTPres.Close
Set oPPTPres = Nothing
oPPTApp.Quit
Set oPPTApp = Nothing
+4

,

, , PowerPoint , , powerpoint . , , - .

B powerpoint , SO - force , .

bruteforce Excel Powerpoint:

Sub ForcePowerpointExit()


Dim BruteForce As String
BruteForce = "TASKKILL /F /IM powerpnt.exe"

Shell BruteForce, vbHide

End Sub

, .

+4

, , , . B. .

, VBA PowerPoint VBA, , .

, .

Powerpoint VBA , (powerpoint).

+1

Set oPPTPres = Nothing , Excel , ()

0

All Articles