Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PresentationBeforeSave

334 views
Skip to first unread message

John Carlier

unread,
Aug 30, 2002, 5:16:51 AM8/30/02
to
I have written a com addin for powerpoint xp, which traps
to the event "PresentationBeforeSave". At this point a
custom interface is presented to allow the user to choose
the location to store the file.

I then try to do a SAVEAS on the presentation to the
location and get the error:-

Run-time error -2147467259 (80040005)
Presentation (unknown member) : Failed.

I have built a simple test in which I do
oPres.SaveAs "c:\j.ppt"
in the event and this too gives the error.

In excel this technique works!!

Ideas ?

John


Mike M.

unread,
Aug 30, 2002, 9:35:41 AM8/30/02
to
Is the presentation still open? I usually get these errors after the
presentation has closed and I try to do something to it.

"John Carlier" <jcar...@vxcompany.com> wrote in message
news:a77b01c25005$f99ade50$3bef2ecf@TKMSFTNGXA10...

Steve Rindsberg

unread,
Aug 30, 2002, 10:22:56 AM8/30/02
to
> Run-time error -2147467259 (80040005)
> Presentation (unknown member) : Failed.
>
> I have built a simple test in which I do
> oPres.SaveAs "c:\j.ppt"
> in the event and this too gives the error.

Assuming that oPres contains a valid reference to a presentation, this will
work.
I'm with MikeM. I'd check to see that you have a valid reference to the
file.

Read up on the timing of the events though. There may be interaction
between the document close (of the original presentation) triggering the
event twice or some such oddity. You might try it with just Save instead of
SaveAs to eliminate that possibility.


Mike M.

unread,
Aug 30, 2002, 1:59:52 PM8/30/02
to
I think it is a timing issue. I trap the presentation close event and then
save the presentation. If the user modified the presentation and hit the
close button without saving PPT shows the do you want to save your changes
dialog. However, the presentation close event has already been fired, I try
to close the presentation and get an error because a modal dialog is
displayed. Maybe the same is happening to you. You get the event but PPT
goes ahead and closes the presentation. Then you try to work with it and it
is not active.


"John Carlier" <jcar...@vxcompany.com> wrote in message

news:938601c25046$358f45f0$37ef2ecf@TKMSFTNGXA13...
> The presentation is New.
> Attached is a simple VB add-in version which causes the
> error.
> The Application pointer triggers the event and I am using
> the activepresentation.
>
> Has anyone tried to do anything like this in a com add-in?
> Has anyone done anything with this event?
> Documentation is very thin. Do you have anything on
> the "timing of events" ?
>
> In fact what I want to do is just change the location
> where PowerPoint will look to save a file, before the
> FileDialog kicks in. However all my attempts to do this
> have failed. I therefore am trying to do it for
> PowerPoint. It worked OK for Excel.
>
> The source of all these problems is that it does not seem
> to be possible to influence the default save location for
> PowerPoint. The common FileDialog appears to have
> different implementations for each of the Office products.
>
> Thanks for your interest.
>
> John

> >.
> >


Steve Rindsberg

unread,
Aug 30, 2002, 2:29:20 PM8/30/02
to
There's a bit of info in MSDN, I'm pretty sure.

But have you gone into PPT, set the default save location in Tools, Options,
then checked PPT's options settings in the registry? Maybe you could get
the job done by setting the right reg entries before PPT starts?

--
Steve Rindsberg PPT MVP
PPT FAQ: http://www.pptfaq.com
PPTools: http://www.pptools.com


"John Carlier" <jcar...@vxcompany.com> wrote in message
news:938601c25046$358f45f0$37ef2ecf@TKMSFTNGXA13...
> The presentation is New.
> Attached is a simple VB add-in version which causes the
> error.
> The Application pointer triggers the event and I am using
> the activepresentation.
>
> Has anyone tried to do anything like this in a com add-in?
> Has anyone done anything with this event?
> Documentation is very thin. Do you have anything on
> the "timing of events" ?
>
> In fact what I want to do is just change the location
> where PowerPoint will look to save a file, before the
> FileDialog kicks in. However all my attempts to do this
> have failed. I therefore am trying to do it for
> PowerPoint. It worked OK for Excel.
>
> The source of all these problems is that it does not seem
> to be possible to influence the default save location for
> PowerPoint. The common FileDialog appears to have
> different implementations for each of the Office products.
>
> Thanks for your interest.
>
> John
> >-----Original Message-----

> >.
> >


John Carlier

unread,
Sep 2, 2002, 8:50:53 AM9/2/02
to
Still can not find anything of use on MSDN...
Nice idea to change the location in the registery, but we
dont know what the user wants before PPT starts and so can
not change before we start. Does anyone know if we can
change the default location via VB code? oApp.Options....?
does not work.

General point: What state do we think PPT SHOULD be in at
the time of the BeforeSave event?

My view is that we should be able to influence things at
this moment. i.e. Save locations etc etc. This is what
happens with WORD and Excel. If we can not do this what is
the point of this event ?

Would anyone from Microsoft like to comment?

John.

>.
>

Steve Rindsberg

unread,
Sep 2, 2002, 9:55:02 AM9/2/02
to
One thing: there isn't a BeforeSave event in PowerPoint. It's
PresentationSave

I haven't worked with it so can't really be of much help here (SHYAM!!!!
Are you watching??) <g>

The Boctor book on programming Office 2000 mentions:

"If ... Powerpoint is in its sequence of closing a document and the changes
to it will be saved, the app calls the document Save event procedure AFTER
the doc Close even procedure."

and

"If PPT is in its sequence of closing a presentation and if changes ... will
be saved, the PresentationSave procedure is called after you close the
presentation's document window. The presentation, however, is still in
memory and can be manipulated. Attempting to change ... the presentation's
document window will result in an error."

--
Steve Rindsberg PPT MVP
PPT FAQ: http://www.pptfaq.com
PPTools: http://www.pptools.com
"John Carlier" <jcar...@vxcompany.com> wrote in message

news:c19001c2527f$5f798980$a4e62ecf@tkmsftngxa06...

John Carlier

unread,
Sep 3, 2002, 2:10:12 AM9/3/02
to
But I am using Office XP. in this version there IS a
PresetationBeforeSave event.

(sorry the xp were lowercase in my original post)

John.

>.
>

Steve Rindsberg

unread,
Sep 3, 2002, 10:20:35 AM9/3/02
to
Ah, sorry. I'm stuck in the late nineties for compatibility reasons. Pah!

--
Steve Rindsberg PPT MVP
PPT FAQ: http://www.pptfaq.com
PPTools: http://www.pptools.com
"John Carlier" <jcar...@vxcompany.com> wrote in message

news:c63a01c25310$90409950$a4e62ecf@tkmsftngxa06...

John Carlier

unread,
Sep 3, 2002, 12:15:32 PM9/3/02
to
No problem- Who or what is SHYAM ?

John

>.
>

Mike M.

unread,
Sep 3, 2002, 1:34:42 PM9/3/02
to
http://www.mvps.org/skp/

"John Carlier" <jcar...@vxcompany.com> wrote in message

news:a63801c25365$20c3f270$36ef2ecf@tkmsftngxa12...

Steve Rindsberg

unread,
Sep 3, 2002, 5:05:05 PM9/3/02
to
Shyam Pillai (and Chirag Dalal, MikeM and don't kick me if I left you out)
are a couple of our real developer regulars here. I'm hoping one of them
will be able to help you with your problem, John.

You might want to have a browse round http://www.mvps.org/skp/ (Shyam's
site) while we're waiting.

--
Steve Rindsberg PPT MVP
PPT FAQ: http://www.pptfaq.com
PPTools: http://www.pptools.com
"John Carlier" <jcar...@vxcompany.com> wrote in message

news:a63801c25365$20c3f270$36ef2ecf@tkmsftngxa12...

Echo S

unread,
Sep 3, 2002, 8:38:07 PM9/3/02
to
"John Carlier" <jcar...@vxcompany.com> wrote in message
news:a63801c25365$20c3f270$36ef2ecf@tkmsftngxa12...

> No problem- Who or what is SHYAM ?

Shyam Pillai is our waaaaay code-savvy PPT MVP upon whom Steve calls (bows
down to) when he gets really stuck. <VBG>

--
***DO NOT POST ATTACHMENTS TO THIS NEWSGROUP***
Echo [MS PPT MVP]
http://www.echosvoice.com


Steve Rindsberg

unread,
Sep 3, 2002, 10:48:25 PM9/3/02
to
> Shyam Pillai is our waaaaay code-savvy PPT MVP upon whom Steve calls (bows
> down to) when he gets really stuck. <VBG>

Got me pegged, doesn't she?


John Carlier

unread,
Sep 4, 2002, 2:44:52 AM9/4/02
to
Ok got the message.

I await the word of the master.....

John.

>.
>

Shyam Pillai

unread,
Sep 4, 2002, 9:57:26 AM9/4/02
to
John,
I am sorry for the delay in responding. It took a while to wade thru several
hundred postings since I've just returned from a fine work/holiday trip.

PowerPoint is quite unique, it never bothers to be consistent with other
apps. Yes, what you state is a known issue however you can resort to a
workaround.
1. Trap the BeforeSave event, cancel the save.
2. In the same event start a timer for a sec delay to invoke a procedure.
3. In the procedure invoked, kill the timer and display the save as file
dialog there and get user filename. Make use of the InitialFilename property
of the dialog box to set the default folder location and file name since if
you set "D:\My location" as
the initialfilename, it will default to that folder.
4. Deactivate the event trap and perform the save.
5. Reactivate the event trap.

If you have problems in coding it. Give a yell.
--
Regards
Shyam Pillai

Handout Wizard
http://www.mvps.org/skp/how/

"John Carlier" <jcar...@vxcompany.com> wrote in message

news:a63801c25365$20c3f270$36ef2ecf@tkmsftngxa12...

John Carlier

unread,
Sep 5, 2002, 2:27:08 AM9/5/02
to
Shyam,

Thank you for your most interesting reply.
I will try it today.

One more question though. In your reply you wrote
"...what you state is a known issue...". I would like to
know where it is known? I have tried the Microsoft sites,
Google, Altaviste etc etc. and found nothing. I would like
to know where to look in the future as this has cost a lot
of time and effort up to now.

Also is there a fix in the works from MS?

John

>.
>

John Carlier

unread,
Sep 5, 2002, 5:22:45 AM9/5/02
to
Ok I have tried your idea and in principle it works.
It raises however a few other points which you may be able
to help with.
Going through your solution

>1. Trap the BeforeSave event, cancel the save.

-- Ok done, But how do I know what triggered me ?
Exit/Close/Save.... Once I cancel the event my code
becomes a "SaveAs", even if the user wants to Exit.

>2. In the same event start a timer for a sec delay to
invoke a procedure.

-- Ok added a form with timer

>3. In the procedure invoked, kill the timer and display
the save as file

>dialog there and get user filename. Make use of the
InitialFilename property
>of the dialog box to set the default folder location and
file name since if
>you set "D:\My location" as
>the initialfilename, it will default to that folder.

-- did this but our end location is in Sharepoint so when
I give the initialfilename
= "http://carliervm01/ds/documents/fold1/test.ppt" it does
not display the contents of this directory in the window.

>4. Deactivate the event trap and perform the save.

-- I did this by setting/testing a global variable. All
the code in the beforeSave is now in a IF/END IF block.
Is this what you mean be Deactivate ?

>5. Reactivate the event trap.

-- see 4


>
>If you have problems in coding it. Give a yell.
>--

-- OK this is the yell


John

Shyam Pillai

unread,
Sep 5, 2002, 9:19:21 AM9/5/02
to
John,
This came up during beta testing and reported, no known fixes for it
unfortunately.
--
Regards
Shyam Pillai

Handout Wizard
http://www.mvps.org/skp/how/


"John Carlier" <jcar...@vxcompany.com> wrote in message

news:c5ca01c254a5$42d57e60$35ef2ecf@TKMSFTNGXA11...

Shyam Pillai

unread,
Sep 5, 2002, 9:17:52 AM9/5/02
to
John,

> -- Ok done, But how do I know what triggered me ?
Exit and Close will fire the PresentationClose event first; PowerPoint fires
the BeforeSave Event later if the file needs to be saved. You can process to
check if the file is dirty and needs to be saved by checking the Saved
property in the Close event itself.

Use an API call to create a timer to avoid the Userform. Check my site for
some code to create an API timer.

> I give the initialfilename
> = "http://carliervm01/ds/documents/fold1/test.ppt" it does
> not display the contents of this directory in the window.

Will check up for SharePoint servers and revert.

Deactivate/Activate the event trap either by a flag or literally setting it
again in code like how you initially set it up.
--
Regards
Shyam Pillai

Handout Wizard
http://www.mvps.org/skp/how/


"John Carlier" <jcar...@vxcompany.com> wrote in message

news:ebd501c254bd$cb7cc8a0$9ae62ecf@tkmsftngxa02...


> Ok I have tried your idea and in principle it works.
> It raises however a few other points which you may be able
> to help with.
> Going through your solution
>
> >1. Trap the BeforeSave event, cancel the save.
>

John Carlier

unread,
Sep 6, 2002, 10:19:08 AM9/6/02
to
I am one step forward, but three back.

I have now modified my code to do the ".SaveAs" to my
SharePoint folder. If all the 'Required' fields for Profil
have been filled then it is ok. However if a required
field is missing then I get an error back.

Using PPT without my Add-in to save to the SharePoint
folder causes the profil form to be displayed.

My code is now on the third level of exception and is
becoming a mess.

My original wish is to be able to modify the default
location where PowerPoint will look to save a file to,
i.e. the initialfilename in the dialog.

Is there no other way to do this ?

John.

Mike M.

unread,
Sep 6, 2002, 1:31:35 PM9/6/02
to
Well, I don't know about that. My company does a similar thing where we
wrap our application around PPT and let users add, modify and delete PPT
presentations. We control the names and directory where they are stored.
What we do is when they want to create a new presentation we let them give
us a name in a VB dialog box. Then we start PPT, create a blank pres, and
immediately do a SaveAs() to the directory where we keep all of them. We
have experimented with disabling the Save As menu item but I think we had
some problems with that. When they modify one we do the same thing, get the
name, prepend our path and open it. We instruct the users to only do a Save
not Save As. There is a margin for error if the user does things we teach
them not to. But it goes back to the sharp stick in the eye thing, "don't
do it". Tthe automation in PPT leaves a little to be desired but you have
to do the best you can with what you got. And that is about as
philisophical as I get!


"John Carlier" <jcar...@vxcompany.com> wrote in message

news:e2e501c255b0$5d414980$a4e62ecf@tkmsftngxa06...

John Carlier

unread,
Nov 8, 2002, 5:39:00 AM11/8/02
to
After some off-line help from Shyam I got a sort of
solution. This was based on starting a timer to trigger an
event 1 second later. Then exiting the
current "PresentationBeforeSave" event and doing the
processing in the timer event. Although this worked for a
save to the normal file system, it generated a simular
error when saving to the URL in SharePoints Web Storage
System. I have now had 'Offical' contact with Microsoft
and they confirm the problems with multitheading event in
PowerPoint.

What is interesting is that I am now rebuiling the Com add-
in using VB.NET. Here I do not get the errors in PPT.
Although these are early days and the code is not yet
complete simple traps and .SAVEAS seem to work.

Has anyone build a com addin using VB.NET ?
If so what are your results?

John.

>.
>

0 new messages