powerpoint automation in "hidden/background" mode

G

Guest

All,

I'm working on a vbscript application that uses Powerpoint Automation.

The app begins with the following code:

Dim oApp
Set oApp = CreateObject("Powerpoint.Application")
oApp.Visible = True

However, I was wondering if it was possible to use Powerpoint Automation
WITHOUT actually showing that to the user - I'd like to have Powerpoint do
the work INVISIBLY to the user.

I've tried this:

oApp.Visible = False

But then nothing seems to work. Is it possible to use Powerpoint Automation
in "background" or "hidden" mode?

Many thanks in advance!

Cheers,
Matt Stuehler
 
T

Tim Hards

Hi Matt,
With PPT2003, I've just tested that I can do the following (in VB - you
might need to adapt it for VBScript):

Dim oApp As PowerPoint.Application
Set oApp = CreateObject("Powerpoint.Application")

Dim pres As PowerPoint.Presentation
Set pres = oApp.Presentations.Open("C:\\test.ppt", , , msoFalse)
MsgBox pres.Slides.Count

The key here is not setting the application window to be visible
(explicitly setting Visible = False caused an error for me), and opening
test.ppt with the WithWindow parameter set to false.

I suspect that some actions will require a window, but as you can see I
was at least able to access the slides collection and get a slide count.

Hope that helps.

--
Tim Hards
Chief Software Architect
Visual Exemplars Ltd

Perspector - 3D Business Graphics for PowerPoint
http://www.perspector.com/
 
S

Shyam Pillai

Hi Matt,
Don't set the visible property to true and PowerPoint will continue the
session invisibly after it's been initialized. There are significant
performance improvements if you performing a lengthy task.
 
G

Guest

Shyam,

Thank you for your response - performance improvements are exactly what I'm
after. However, I run into this problem:

Dim oApp
Set oApp = CreateObject("Powerpoint.Application")
Dim oPres
Set oPres = oApp.Presentations.Open("C:\Test.ppt")

When I run this, I immediately get this error:

"Presentations.Open : Invalid request. The Powerpoint Frame window does not
exist."

It seems that, if I run Powerpoint "invisibly", there are certain things you
cannot do - like open a .ppt file. Is this correct? What can you do, and not
do, when Powerpoint is "invisible?"

Many thanks in advance!

Cheers,
Matt
 
S

Shyam Pillai

The last argument of the Open method is the WithWindow, set it to false and
then open the presentation. This will work just fine.
 
G

Guest

Shyam,

Your solution works perfectly. Thank you very much for your expertise.

I've noticed one strange problem though...

When I use vba/vbscript to add content to powerpoint tables, and Powerpoint
is in "visible" mode, then the table cells resize automatically to fit the
content - this is the desired behavior.

When I run the vba/vbscript in Powerpoint in "hidden" mode, however, the
table cells don't resize as they should.

Is there some command that tells tables to resize to fit the content that
works when Powerpoint is in hidden mode?

Many, many thanks in advance!

Cheers,
Matt Stuehler
 

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