Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically entering an Excel Addin 2

Status
Not open for further replies.

sfriday

IS-IT--Management
Feb 23, 2002
211
DE
All,

I have an Excel addin .XLA that I need to get into everybodys Excel application.

How can I do this from VBscript. I do not want to open excel, can I manipulate the registry to enter it??

Steve
 
'For install an addinn named "MyAddInn.xla" in the Template
'folder you have to stop Excel and run the next script
'having the addin in the same folder

Set Sh = createobject("WScript.Shell")
Set Ex = createobject("Excel.Application")
With Ex
Templ = .application.TemplatesPath
End With
Ex.Quit
path = Wscript.ScriptFullName
Cale = Left(path, InstrRev(path, "\"))
Set fso = createobject("scripting.filesystemobject")
If fso.FileExists(Cale&"MyAddInn.xla") then
Set Adr = fso.GetFile(Cale&"MyAddInn.xla")
On Error Resume Next
Adr.Copy(Templ&"MyAddInn.xla")
If Err.number <> 0 Then
Sh.PopUp &quot;Excel is open having MyAddInn.xla installed. &quot;&vbcrlf&_
Err.Description& &quot; - Copy over AddInn opened !&quot;&vbcrlf&_
&quot;In 10 seconds we will stop !&quot;,6,&quot;Worning !!!&quot;,48
Err.Clear
WScript.Quit
End If
Else
Sh.PopUp &quot;The file MyAddInn.xla is not in the active folder. We will stop !!&quot;,10,&quot;Worning&quot;,48
WScript.Quit
End If
On Error GoTo 0
Set Ex = createobject(&quot;Excel.Application&quot;)
With Ex
.Workbooks.Add
.Application.Addins.Add(.Application.TemplatesPath & &quot;MyAddInn.xla&quot;).Installed = True
Set a = .Application.AddIns(&quot;For Test&quot;) 'The Title - In Properties - Summary
If a.Installed = True Then
Sh.PopUp &quot;MyAddInn.xla installed !&quot;,6,&quot;Confirmation !!!&quot;,48
Else
MsgBox &quot;Problems !?!&quot;
End If
End With
Ex.quit

Sh.PopUp &quot;The instalation closed succesfully !&quot;,10,&quot;End !!!!&quot;

' Is that what you want ?
' I did not check what I did, but this is the idea of the script
 
Thanks, I will test tonight and Let you know.

Where do you find out about all these fields that can be used IE Applications.Addin.Add etc??

Steve
 
Thanks mate worked a treat, little change as the addin is not in the default template path but other than that all is well

So I gave you a nice big star.

Once again

Thanks

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top