Solved

Script to Copy xla and add them

Posted on 2010-09-23
2
494 Views
Last Modified: 2012-05-10
I'm trying to copy 7 xla files to the "%appdata%\Microsoft\Addins" folder then add them to excel.

When executing the script (script attached) I receive the following error:
Error: Object required: '[string: "\\SERVER\DATA"]'
Code: 800A01A8
Source@ Microsoft VBScript runtime error

As well as rectifying this error, I'd like to know how to modify this code so it runs through 7 addins.
Addin1.xla
function2.xla
exceladdin.xla
testaddin.xla
Addin5.xla
buttosn.xla
savings.xla

Regards
Set SourceLocation="\\SERVER\DATA\Addin1.xla"



AppData=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%APPDATA%")

Set DestinationLocation=AppData & "\Microsoft\Addins\"

CreateObject("Scripting.FileSystemObject").CopyFile SourceLocation, DestinationLocation, True



On Error Resume Next

Dim oXL

Dim oAddin

Set oXL = CreateObject("Excel.Application")

oXL.Workbooks.Add

Set oAddin = oXL.AddIns.Add(Source, True)

oAddin.Installed = True

oXL.Quit

Set oAddin = Nothing

Set oXL = Nothing

Open in new window

0
Comment
Question by:cbsbutler
  • 2
2 Comments
 
LVL 1

Expert Comment

by:rd1966
ID: 33742921
Remove the SET from line 1 and 4 to get rid the error.

0
 
LVL 1

Accepted Solution

by:
rd1966 earned 500 total points
ID: 33742956
I haven't test this, but could you put it in a subroutine?
CopyFile "\\SERVER\DATA\Addin1.xla"

CopyFile "\\SERVER\DATA\function2.xla"

...



Sub CopyFile(sourceLocation)

	SourceLocation="\\SERVER\DATA\Addin1.xla"

	AppData=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%APPDATA%")

	DestinationLocation=AppData & "\Microsoft\Addins\"

	CreateObject("Scripting.FileSystemObject").CopyFile SourceLocation, DestinationLocation, True

	

	On Error Resume Next

	Dim oXL

	Dim oAddin

	Set oXL = CreateObject("Excel.Application")

	oXL.Workbooks.Add

	Set oAddin = oXL.AddIns.Add(Source, True)

	oAddin.Installed = True

	oXL.Quit

	Set oAddin = Nothing

	Set oXL = Nothing



End Sub

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now