Addin Install

G

Guest

Yesterday you helped me to determine how to install an add-in through vba,
thank you for that.

Now I am trying to get past the alert boxes which ask if I would like to
overwrite the add-in if it currently exists. The two messages I get are:
"Copy XXXX.xla to the add-ins folder?" (Yes/No/Cancel), and "A file named
XXXX.xla already exists. Do you want to replace it?" (Yes/No/Cancel).

Is there a way to program the code not to ask these questions? It will not
work if I set Application.DisplayAlerts = False because it defaults to
answering "No." Or at least the way I have it running. How can I correct the
code to answer "Yes," but not display the alerts? Below is an example of what
I am currently using.

Thank You,

Sub AdinInstall1A()

Application.DisplayAlerts = False

On Error Resume Next
Application.AddIns.Add Filename:="C:\XXXX.xla"
Application.AddIns("XXXX").Installed = True

Application.DisplayAlerts = True

End Sub
 
G

Guest

Check if the addin is currently installed. If it is then uninstall it and
delete it. You can then add your new addin version back with no problems (I
assume you are re-versioning the addin?)...
 
G

Guest

Yes, in many cases I would be re-versioning the addin. However for new users
it would be an initial setup. What if the addin exist on the users computer,
but is not installed? How should I check for this? Also, concerning deleting
the add-in would that code be somewhat like:
Application.AddIns.delete Filename:=(the file name on the users C drive
under application data)

Thank you,
 
P

Peter T

What if the addin exist on the users computer,
but is not installed? How should I check for this?

Under on error resume next attempt to set a reference
set adn = addins(sTitle)

where sTitle is the title in file/properties if it has one, otherwise the
name without extension

If the ref succeeds then check its installed property.
You could also check if it's loaded, which it may or may not be irrespective
as to whether it's in the addins collection and/or installed (user could
have loaded from an icon or manually or unloaded)

Note that addins in the collection, whether or not installed, are defined by
only the title, not path. Eg if you try to do this -

set adn = addins.add("C:\myAddin.xla")
adn.installed = true

- and there's another addin with same title (note title) in another folder
that's in the collection then a ref will be set to that addin to be
installed and load if not already - not yours.

It's worth setting a unique title, eg "My Addin v12,34"

Regards,
Peter T
 
G

Guest

Hi tjh,
Not all application alerts can be suppressed with .DisplayAlerts!

Note that the Add method of the Addins collection supports an option Boolean
argument for the copy. Set it to TRUE or FALSE as desired, to suppress the
prompt.

Also note that the CopyFile method has an optional Boolean argument to
overwrite an existing file with the same name. Setting this to TRUE will
simply copy the file (replacing any existing one with the same name).

<FWIW> If you're just looking for a simple way to update users' addins, I
suggest you use the same filename and put version/release info in its Summary
Properties. This will display in the tooltip in explorer windows. If the
addin is already installed, the next time Excel is opened it will look for
the same filename but get the new version you just put in the source folder.
...No need here to re-install it!

The message you say you're getting indicates that Excel is attempting to
copy the file to the user's addins folder. I think it would be better to
store it in its own folder under "Program Files" if on a local machine. If
it's stored on a network drive, any user-accessible location for its folder
will do. When asked if you want to copy it to the user's addin folder, say NO
to this prompt because:
1. You want all users on the network referencing the same file from the
server location. This makes maintenance easier for you because there's only
one file to update.
2. You want the same addin available to all users of a local machine (I
would think).

Note that you can overwrite an addin file at any time, but it won't be
current for your users until their copy of Excel is re-opened.

As for distribution:
I'm not sure why you're trying to install it programmatically, but using
TOOLS, ADD-INS, BROWSE... will get it done even for the most novice user.
Putting a simple instruction in a text file would be equally effective, and
it's one less addin for you to maintain. Alternatively, for your updates, a
Winzip Self-Extracting file works nice for stand-alone machines.

HTH
Regards,
Garry
 

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