running a script when the file closes

Y

yanwei

Hi

In powerpoint 2003

I want to:

1. save the current presentation into a temp file
2. open the saved temp file as an presentation that hasn't been saved
or named
3. close the current presentation
4. deleted the temp file

is it possible?

Order isn't very important, as long as I end up with only one open
presentation and that presentation hasn't got a name or saved status.

I can do it in powerpoint 2000, but that's only because the VBA code
will continue to run for the current presentation even after I close
the presentation.

Hmm... wonder if I make sense.
yanwei
 
Y

yanwei

Hi Steve

Here is bits of my code. There is something to note, without the
currPath, it will work in powerpoint 2000, but it will not work for
2003 or 2002. Or saved to soemwhere I don't know.

....
ActivePresentation.SaveAs currPath & "\" & fileName,
ppSaveAsPresentation
With PowerPoint.Presentations.Open(currPath & "\" & fileName,
msoFalse, msoTrue, msoFalse)
.Application.Visible = msoTrue
.Saved = msoFalse
End With

PowerPoint.Presentations(currPath & "\" & fileName).Close
objFS.DeleteFile currPath & "\" & fileName, True
....


this works ok in powerpoint 2000. However in 2002 and 2003 I couldn't
seem to open the file again, and once the .close statement is ran, the
whole thing terminated. So the .DeleteFile statement doesn't see to
have been reached. I cannot delete the file until I close it.

The behaviour when I run the script in the editor is it will totally
close once the .Close statement has executed.

However, if I run it as a slide show, it will get to the end. It will
open up PowerPoint 2002 (the version that's installed) and go to the
end of the script. I know by having MsgBox after the .Close statement.
However, when powerpoint started up, it does not contain the file that
should be opened with. Am I missing something here?

Thanks
Yanwei
 
Y

yanwei

Hi Steve

Sorry for the confusion. The file I want to open is a .ppt file. I want
to open a different file when a certain .pps file is ran and the user
has not opened a PowerPoint application window.

I managed to get it working now. I was relaying on the last argument of
the .open funtion to open powerpoint for me.

By doing:
PowerPoint.Presentations.Open(fileName, msoFalse, msoTrue, msoFalse)

PowerPoint 2000 application window will open automatically. However,
when I run this using PowerPoint 2002 and 2003, I fail to see the
required open at all. However, when I do change the last argument to
true, and while PowerPoint 2002 and 2003's application window is open,
I can see the file open. But if the PowerPoint application window isn't
open at the time when I run the PPS file, it will not work at all. And
this also causes odd behaviour in 2000 (can't remember what now).

In terms of actual logic, setting the last argument to false is wrong.
If the last argument (visible window) is set to false, then it should
not be visible. So the behaviour of PowerPoint 2002 and 2003 is
correct, while 2000 is not. However, I was relaying on something
illogical to make the PowerPoint application window visible for me.
Before I saw that, I was left wondering why. After a while, I saw the
incorrect thinking in my script. All I need to do is to make the
PowerPoint application window visible and setting the last argument of
the open method/function to be visible.

So this was all I need to do:

With PowerPoint.Application
.Visible = msoTrue ' <- This is the line that I needed
With .Presentations.Open(fileName, msoFalse, msoTrue, msoTrue)
.Application.Visible = msoTrue
.Saved = msoFalse
End With
End With

Sorry for the trouble, and thanks for you help.
Yanwei
 

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