VBA: PowerPoint fails to close on Quit() function

M

Mark Findlay

I am using VBA to print out PowerPoint presentations from a web page. I use
javascript. It all works fine, except that PowerPoint fails to shutdown upon
using the Quit() function. Is there something I am missing? I use similar
code to create the vba object for WORD and EXCEL and when I call their
Quit() functions they close just fine. Only PowerPoint fails to close.

Here is the code I use:

function PrintPresentation()
{
var oPPoint=0;
oPPoint = new ActiveXObject("PowerPoint.Application");
oPPoint.Visible = 1;

oPPoint.Presentations.Open(sFilename,0,0,1);
oPPoint.ActivePresentation.PrintOut();
oPPoint.ActivePresentation.Close();

oPPoint.Quit(); // <--- this is failing to shutdown PowerPoint
}

Any advice would be greatly appreciated!

Thanks!
M
 
A

Alex K. Angelopoulos [MVP]

My guess would be something it things it has to save. Does the document
actually close? If not, you might want to try using the extended form of
the ActivePresentation.PrintOut() routine, actually printing the document
without formally opening it.
 
M

Mark Findlay

Thanks Alex, but I am unfamiliar with the 'extended form' of the PrintOut()
function. Would it be possible to show me an example of such as usage?

Many thanks!
M
 
P

Peter Huang [MSFT]

Hi Mark,

The problem may be because the COM object(PowerPoint.applicaiton object)
was not been released immediately.
You may try the code below to see if the problem persists.
var idTmr = "";
function button1_onclick() {
var oPPoint;
oPPoint = new ActiveXObject("PowerPoint.Application");
oPPoint.Visible = true;
oPPoint.Presentations.Open("C:\\test.ppt",0,0,1);
oPPoint.ActivePresentation.PrintOut();
oPPoint.ActivePresentation.Close();
oPPoint.Quit();
idTmr = window.setInterval("Cleanup()",1);
}
function Cleanup() {
window.clearInterval(idTmr);
CollectGarbage();
}

Here is a helpful Knowledge Base article.
http://support.microsoft.com/default.aspx?scid=kb;en-us;164494
Have a try and let me know if this does the job for you.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top