change path to an add-in

B

Brian Murphy

If an xla add-in has been installed from folder A to the add-ins
collection, and I want to redirect it to another folder B, can this be
done from VBA?

Thanks,

Brian Murphy
 
B

Barb Reinhardt

It's not clear what you want to do? Move the add-in to Folder B or open a
file in Folder B? Or something else?

Barb Reinhardt
 
J

Jon Peltier

Brian -

You need to uninstall the add-in, then add and install the add-in from the
new location:

AddIns("My Add-In").Installed = False
Set myAddIn = AddIns.Add(Filename:="C:\New Path\MYADDIN.XLA")

AddIns("My Add-In").Installed = True

- Jon
 
P

Peter T

It might not be not straightforward. If the addin originally was not in one
of the default library paths it'll be difficult to remove it from the addins
collection, after say uninstalling it and moving it (Name..As) to a
different folder. You'd be able to "apparently" add it back to the addins
collection but probably won't "install". No problems though if you rename
the addin after moving it, and ideally its title after first reloading as a
workbook. Might need to do it all in two sessions, first uninstall and move,
second session re-install

A better approach would be to amend the path in the OPENx key in the
registry (which can be done programmatically) along similar lines to an
installer.

Another thing you may need to do is update links in any wb that has the
addin's udf's in formulas.

It's a bit vague though as to what you are trying to do, what have you
attempted to do.

Regards,
Peter T
 
B

Brian Murphy

The addin contains the following in its Auto_Open

Application.AddIns.Add ThisWorkbook.FullName

This puts the addin in the list in the Add-Ins dialog box, with the
check box empty.
If I close and reopen excel, it's still in the list. This is what I
want as it "installs" the addin for me.

If the addin is then opened manually from another folder, that .Add
statement above gets run and this seems to redirect the addin as being
installed from the second folder, but closing and reopening excel
shows that it's still "installed" from the first folder. This is not
what I want.

What is the right and proper way to "install" and "uninstall" an
addin. In this case I don't have to worry about links to UDF's in the
addin because this addin isn't used for that sort of thing. Can
registry settings be easily changed for any excel version?

Could a small VB6 program be used to launch one or more instances of
Excel to do the uninstalling and installing?

Thanks,

Brian
 
P

Peter T

What you describe relates to the problem there is no direct way in VBA to
"Remove" an addin from the collection, and what I was trying to explain
previously. When you reinstall it from a new folder, the collection will
continue to "think" it is still in the old location. Also it will probably
not install by doing ad.Installed = True (after loading and re-adding to the
collection from it's new location).

Manually the way fully uninstall from the collection is to uncheck it,
remove it from file, attempt to re-check it, then accept the prompt to have
it removed from the list. I vaguely recall someone suggesting SendKeys to do
that but I've never tried.

With code, the only way to fully "remove" from the collection is by writing
to the registry (unless the addin is in a default library folder which makes
things easier). Indeed this can be done with a VB6 app, KeepItCool posted
full code in this ng to do just that (Excel must be closed). If you don't
want to go that route, try doing it along the lines I suggested - in two
sessions. Should work but will end up with the old defunct entry in the
non-installed list of addins in the registry (harmless clutter).

Note with addins "(un)Install" has two distinct meanings, install into the
addins collection and install such that it will auto-load at start-up.
Further, an addin can be installed in both senses yet not necessarily
loaded.

Regards,
Peter T
 
B

Brian Murphy

I have created a VB6 program using KeepItCool's posted code.
I call the VB6 program from my NSIS installer.
In my limited testing so far it works great!

Thanks for the great tip, Peter.
I've wanted to do this addin install/uninstall stuff for years, and
now I can :)

If I knew how to put a link to the specific post with the code, I
would.
Here is the header for the post.
Newsgroups: microsoft.public.excel.programming
From: keepITcool <[email protected]>
Date: Sat, 16 Oct 2004 04:58:50 -0700
Local: Sat, Oct 16 2004 6:58 am
Subject: Re: remove add-in entry via registry

Cheers,

Brian
 
P

Peter T

Glad you got it working.

I've never used the NSIS installer although I've had it on my system for
years. A quick look in help suggests all can be done in the NSIS script
without the need for the separate VB6 app.

Regards,
Peter T
 
B

Brian Murphy

Jon,

That's the one. How does one go about getting a direct url to a
specific post?

I think I got it.
Click on 'More options" on the right.
Right click on "Individual message" and go "copy link location"

Is this how you did it?

Brian
 
B

Brian Murphy

That's interesting. I didn't think about doing it within NSIS.

But if I had, I still would have done it with VB6 because I consider
that to be a much easier route. Especially since KeepItCool had
already written the VB6 code.

Brian
 
J

Jon Peltier

I use Inno Setup for my installations, and usually just call my VB6 exe at
the end of installation. I know I can do the registry stuff from Inno, but
I'm not very good with the Pascal scripting.

- Jon
 

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