Startup routines

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Using VBA with PPT 2002 - Is there any way to detect whether PowerPoint was
started by opening a file or just the application? I'm trying to detect
this, so that if the program was started by opening a file, the file opens
normally, but otherwise, I'll display a custom form I've created. I've
looked through the events, and I can see how I could show the form if a file
opens - but I'm trying to show the form if the file doesn't open.
Thanks
 
Using VBA with PPT 2002 - Is there any way to detect whether PowerPoint was
started by opening a file or just the application? I'm trying to detect
this, so that if the program was started by opening a file, the file opens
normally, but otherwise, I'll display a custom form I've created.

Depending on the user's settings and PPT versions, PPT might start up with no
file open.

It might start a new presentation called Presentation1 but it won't yet have
been saved.

Put something like this in Sub Auto_Open() of an addin so it runs when PPT
starts up:

Dim bShowMyForm as Boolean

If Presentations.Count = 0 Then
bShowMyForm = True
Else
If ActivePresentation.Saved Then
bShowMyForm = True
End If
End if

If bShowMyForm Then
' Show your form
End If



--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================
 
Steve- thanks for your response. Unfortunately - this isn't doing the trick.
The problem is the order that events seem to be executed. My Auto_Open
routine runs before PP gets to opening a file. So everytime I run it,
Presentations.Count is always equal to 0 whether I open the app directly or
double-click on a file to open it. So with the code you provided, my code
will always run, even if the user opened the app by double-clicking a file.

As I see it, my problem is that I'm trying to run my code if an event
doesn't happen. I tried putting in app_PresentationOpen but that only fires
when a presentation opens. I need my code to run only if
app_PresentationOpen doesn't fire. Looking for the non-occurrence seems to
be my stumbling block.

In your response, you mentioned that it might start with Presentation1 or it
might not. Is there a way to always start with a Presentation1 when the app
was opened directly. This way I could watch for the open event with
Pres.Name = Presentation1 then close that one and run my code.

Thanks for your thoughts.

Peter

 
Steve- thanks for your response. Unfortunately - this isn't doing the trick.
The problem is the order that events seem to be executed. My Auto_Open
routine runs before PP gets to opening a file. So everytime I run it,
Presentations.Count is always equal to 0 whether I open the app directly or
double-click on a file to open it. So with the code you provided, my code
will always run, even if the user opened the app by double-clicking a file.

Yes, I see the problem.
In your response, you mentioned that it might start with Presentation1 or it
might not. Is there a way to always start with a Presentation1 when the app
was opened directly. This way I could watch for the open event with
Pres.Name = Presentation1 then close that one and run my code.

As far as I can tell, Powerpoint 2003 and, I think, 2002 will always start a
new presentation on startup. Anybody want to tell me I'm wrong? Please jump
in. PowerPoint 2000 and prior have a user setting that pops up a dialog that
asks what you want to do, start a new presentation, open an old one, etc? If
you cancel out of that, you're left with no presentation open at all, so they'd
be less predictable.

Wild thoughts. What if you were to use the Sleep API - put your AutoOpen to
sleep for a second or two (presumably giving PPT time enough to brush its
teeth, shave and pull up its socks ... ) and THEN you check for Presentation1

Already thought of and tried Command$ - for some odd reason it's implemented in
PPT VBA but never seems to return anything, even though PPT was started with
the name of a file on the command line.


Thanks for your thoughts.

Peter


--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================
 
Back
Top