Kill statement fails

  • Thread starter Thread starter c mateland
  • Start date Start date
C

c mateland

I'm using a simple Kill statement in a auto_open ppa that refuses to
run correctly. I get a permission denial (70), but it seems to be a
just problem with timing. In debugging, I can step through without a
hiccup, but when I run the code, it fails at the Kill statement. Yet
when I continue the run with F5 or step through it, the Kill statement
excecutes fine again.

It's as if PowerPoint wanted to wait a minute for the actions to catch
up or something.

FWIW, the file being killed is a ppa that was lines earlier removed,
unloaded, unautoloaded, etc. from my addins. I then delete the file.
Pretty simple, I would think.

I tried DoEvents after each removal action from my list of addins. But
that didn't work.

Any thoughts or can someone tell me my error?

v2002

FWIW, here's a snippet...

'I just captured the name of the addin I want toasted...
If Application.AddIns(sUserPpaMainName).Loaded = msoTrue Then
Application.AddIns(sUserPpaMainName).Loaded = msoFalse
DoEvents
Application.AddIns(sUserPpaMainName).AutoLoad = msoFalse
Application.AddIns.Remove sUserPpaMainFullPth
DoEvents
End If
Kill sUserPpaMainFullPth
'<choke - until I step through it.>
 
I'm now seeing that any action of unloading/removing an addin prevents
killing the ppa file in the same procedure.

Yet, it seems obvious to me that I have to first unload/remove a ppa
from the addin list before killing the file. Right?

So, how do you, unload/remove the ppa addin and then kill the file?
 
C mateland said:
I'm now seeing that any action of unloading/removing an addin prevents
killing the ppa file in the same procedure.

Yet, it seems obvious to me that I have to first unload/remove a ppa
from the addin list before killing the file. Right?

So, how do you, unload/remove the ppa addin and then kill the file?

Can you rename it? If so, have your "control/update" ppa check for the renamed
file at startup and delete it then. That's assuming it and the replacement
you're loading have different filenames (perhaps a version number appended to
the regular filename)?
 
Steve said:
Can you rename it? If so, have your "control/update" ppa check for the renamed
file at startup and delete it then. That's assuming it and the replacement
you're loading have different filenames (perhaps a version number appended to
the regular filename)?

No, it's getting the same sort of error where it's a question of
timing. Once I restart the code, it runs fine. It's that the code stops
because it thinks it can't delete the file because it's tied up with
PowerPoint.

I saw in the Excel group a person suggested a loop where it keeps
trying to delete until it finally does, but I couldn't get that to
work. I think it finally gave up after a gazillion iterations.

This seems like it should be so simple yet I can't figure it out. I
just want to unload a ppa and then delete the file.
 
C mateland said:
No, it's getting the same sort of error where it's a question of
timing. Once I restart the code, it runs fine. It's that the code stops
because it thinks it can't delete the file because it's tied up with
PowerPoint.

I saw in the Excel group a person suggested a loop where it keeps
trying to delete until it finally does, but I couldn't get that to
work. I think it finally gave up after a gazillion iterations.

That sounds right ... if PPT doesn't turn loose of the file until it quits (which
is, in my experience, what happens) then the loop would run forever. Nice way to
fill up all those otherwise unused clock cycles you'd just be wasting otherwise,
though. said:
This seems like it should be so simple yet I can't figure it out. I
just want to unload a ppa and then delete the file.

I think we're back to my other suggestion then. Give your PPA files sequential
names as you update them; if nothing else, it'll help you keep track of which
version's installed where.

And you should be able to

- unload MyAddin_2005-08-01.PPA
- load MyAddin_2005_08-04.PPA

with no problems. Leave the old addin file there.

On next startup, iterate through the addins collection to find out what the last
bit of MyAddin_ is (to learn the current version) then enumerate all the
MyAddin_*.PPA files in the same folder and delete all but the current one.

Deferred house-cleaning. It's a guy thing. ;-)
 
I have another idea for you. Depending on your situation, it may or may not be a
good solution, but here goes.

Instead of trying to update an addin that's already loaded, how about this:

Start PPT with a script or bat file instead of directly.
The bat file looks for Whatever.PPA in an \Update folder
If it finds it, it copies the file to Whatever.PPA in the folder where your
Whatever.PPA addin is installed then deletes it from the update folder.

Then it fires off PPT. Which now loads the new, updated copy.

Or

Auto_Close in your addin fires off an EXE that sleeps for, say, five minutes while
PPT shuts down, then wakes up and does the same Check For Updated Files and Copy If
Present process.

Or

Instead of loading the PPA you need to replace from time to time, let your "loader"
addin load it for you. IOW:

PPT starts
Your "Loader" PPA autoruns
It checks for updated versions of Whatever.PPA
If it finds one, it copies it to the target folder
It loads Whatever.PPA (which is by now the updated one)

I like the last one best.
 
Steve said:
Or

Instead of loading the PPA you need to replace from time to time, let your "loader"
addin load it for you. IOW:

PPT starts
Your "Loader" PPA autoruns
It checks for updated versions of Whatever.PPA
If it finds one, it copies it to the target folder
It loads Whatever.PPA (which is by now the updated one)

I think I follow you on this one, and I'm about to try it. Instead of
the subject ppa already being loaded (no autoload) the loader ppa
checks for newer version of the subject ppa and if one is found,
replaces the old one and then loads it (but no autoload). If a newer
subject ppa is not found then the existing one is loades, but again, no
autoload. This way, the subject ppa is never loaded at startup and
might then prevent the permission error when I go to kill it.

But I'm thinking somewhere will have to be an autoclose that removes
the subject ppa so that it isn't being used by PowerPoint at all upon
the next startup.

I'll let you know here in a few. Thanks.
 
c said:
I think I follow you on this one, and I'm about to try it. Instead of
the subject ppa already being loaded (no autoload) the loader ppa
checks for newer version of the subject ppa and if one is found,
replaces the old one and then loads it (but no autoload). If a newer
subject ppa is not found then the existing one is loades, but again, no
autoload. This way, the subject ppa is never loaded at startup and
might then prevent the permission error when I go to kill it.

But I'm thinking somewhere will have to be an autoclose that removes
the subject ppa so that it isn't being used by PowerPoint at all upon
the next startup.

So far this is working. I'll have to conduct more tests to check other
scenarios, but so far so good. And I didn't need an autoclose to remove
the subject ppa. By using only the load statement (not autoload) it is
not installed upon the next startup of PowerPoint, so there's nothing
to remove.

If this continues to work with all my imagined scenarios, this will
enable me to change automation by changing the subject ppa in my
network folder and all users will pick it up just by opening PowerPoint
with the loader ppa installed. Does that make sense?

Also, do you see any reason to use an autoclose event? So far I haven't
had the need, but I want to be sure I'm not missing anything. Is it
common to incorporate an autoclose command?
 
I think I follow you on this one, and I'm about to try it. Instead of
the subject ppa already being loaded (no autoload) the loader ppa
checks for newer version of the subject ppa and if one is found,
replaces the old one and then loads it (but no autoload). If a newer
subject ppa is not found then the existing one is loades, but again, no
autoload. This way, the subject ppa is never loaded at startup and
might then prevent the permission error when I go to kill it.

Bingo. Got in one.
But I'm thinking somewhere will have to be an autoclose that removes
the subject ppa so that it isn't being used by PowerPoint at all upon
the next startup.

No, if it's not set to autoload, it won't. Autoload, that is.
 
So far this is working. I'll have to conduct more tests to check other
scenarios, but so far so good. And I didn't need an autoclose to remove
the subject ppa. By using only the load statement (not autoload) it is
not installed upon the next startup of PowerPoint, so there's nothing
to remove.

Would I lie to you??? ;-)
I have a whole set of macros that work exactly this way; one loader takes care of
everything else; the loader's the only one set to autoload. It's been working nicely for
years now.
If this continues to work with all my imagined scenarios, this will
enable me to change automation by changing the subject ppa in my
network folder and all users will pick it up just by opening PowerPoint
with the loader ppa installed. Does that make sense?

Yes, but for one thing: when the users pick up the new PPA, be sure to copy it to a
local folder; you don't want them running shared copies of it.
Also, do you see any reason to use an autoclose event? So far I haven't
had the need, but I want to be sure I'm not missing anything. Is it
common to incorporate an autoclose command?

Only if you need to do some cleanup; removing toolbars or something like that. There's
no "Good Programming Practices" rule that says you should always use one. But do be
careful to put Option Explicit at the top of each module and brush after every meal.
 

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

Back
Top