Question About Conditionally Running a PowerPoint Add-In

C

c mateland

Inside a .ppa add-in for PowerPoint, I have created a large Auto_Open
procedure, which obviously runs automatically upon PowerPoint startup.

However, I'm trying to find a strategy to make the code run ONLY upon
'normal' startup of PowerPoint, and not to run if PowerPoint starts due
to the launching of a PowerPoint file or a PowerPoint file having been
opened from inside Internet Explorer. In other words I want it to run
only when PowerPoint is directly launched.

Does anyone have any thoughts or solutions for this?

Thanks.

(PPT v2000-2003)
 
S

Steve Rindsberg

Auto_Open subs in PowerPoint add-ins only run when the add-in first loads
(when you load it using Tools, Add-ins or thereafter when PPT starts up).

Are you seeing behavior that suggests otherwise?
 
C

c mateland

No, they run just that way, as they should. But I want them to run ONLY
when PowerPoint starts via a user-direct launch of POWERPNT.EXE, as in
the user clicked the icon from the START menu. I do NOT want the code
to run when PowerPoint launches via the user clicking a .ppt file in
Windows Explorer.

Pardon the explaination, but I don't know the terminology to
differentiate those two types of program launches. But it seems somehow
there's a techinal difference, which is made obvious by how the program
starts. A direct launch provides a default blank file versus no such
file launching via starting an existing ppt file. A direct or
ppt-file-start launch creates a visible session of PowerPoint versus a
pps-file-start or Web-link-file-start creates a non-visible session of
PowerPoint that then auto-exits.

I'm questioning if there's a method whereby I can tap into that
differentiation, and make my code run only when the "direct" launch
takes place.

The reason I'm researching this is because my code might unnecessarily
tie up the opening of pps file when the user just wants to simply
present a show. Also, in v2000 (only) the code inexplicitly starts a
VISIBLE session of PowerPoint when a pps or Web-ppt/ppa is launched,
and it doesn't auto-exit. So, if I could create a conditional run based
on HOW PowerPoint launched, it could solve these caveats.

Did that clear up the mud at all? If this is just a pipe dream let me
know so I can click my ruby slippers and go back home.

Thanks.
Chuck
 
S

Steve Rindsberg

C mateland said:
No, they run just that way, as they should. But I want them to run ONLY
when PowerPoint starts via a user-direct launch of POWERPNT.EXE, as in
the user clicked the icon from the START menu. I do NOT want the code
to run when PowerPoint launches via the user clicking a .ppt file in
Windows Explorer.

Ah, yes. That make sense.

Normally Command$ would help here (nothing on the command line? the user just
started PPT's exe) but although it's allegedly supported in PPT VBA, it never
seems to return anything.

The problem I keep running into is that ... so it seems to me ... PPT fires
Auto_Open before it's really initialized everything and opened whatever
presentation it's going to open, if any. For example, Presentations.Count is zero
whether you fire the EXE directly or doubleclick a PPT, etc. No joy there.

I wonder whether it'd be possible to do something conceptually like:

Sub Auto_Open
NapUntilPPTWakesUp
End Sub

Sub NapUntilPPTWakesUp()
While Presentations.Count = 0
Doevents
Sleep(100) ' call Sleep API, 1/10 sec
Wend
' Now do whatever testing's necessary, for example:
If ActivePresentation.Name = "Presentation1" Then
' blank presentation
End if
End Sub

I think I'd add some code to set a limit on how many times that loop executes.
Forever's a long time.
 
C

c mateland

Normally Command$ would help here (nothing on the command line? the user just
started PPT's exe) but although it's allegedly supported in PPT VBA, it never
seems to return anything.

Where can I learn more about Command$? I can't find it in VBA help or
at MSDN.

-Chuck
 
S

Steve Rindsberg

C mateland said:
Where can I learn more about Command$? I can't find it in VBA help or
at MSDN.

It's actually in VBA help but VBA help ... well. I can't adequately express how
bad it is w/o resorting to inappropriate language.

If you have PPT2003, go into the IDE, choose Help then open the item for

MS Visual Basic Documentation
Visual Basic Language Reference
Functions
A-C

Scroll down to Command or Command$ where you'll find a wee, lost help entry on
what Command does in VB. It seems to have no place in VBA. It doesn't throw
errors but it doesn't do anything useful. I just tried it again specifically in
this situation to see if it returns PowerPoint's command line on startup.

No joy.
 
C

c mateland

MS Visual Basic Documentation
Visual Basic Language Reference
Functions
A-C

Scroll down to Command or Command$ where you'll find a wee, lost help entry on
what Command does in VB. It seems to have no place in VBA. It doesn't throw
errors but it doesn't do anything useful. I just tried it again specifically in
this situation to see if it returns PowerPoint's command line on startup.

No joy.

Thanks, Steve. I found it, and, like you, don't see any application for
it but only in theory.

I've now done enough research without results to give up, but the
answer may still be out there. If you happen to run across something,
please let me know and I'll do the same by posting it here should I
find a solution.

Thanks,
Chuck
 

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