?
Solved

Script to Copy xla and add them

Posted on 2010-09-23
2
Medium Priority
?
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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