I made a Deploy project in VS2003. The setup copy a xla and a xlt a specific
Program files folder. After the copy, i want to execute a .vbs that will
copy and register the xla and the xlt. My problem is to get my new program
files folder. Is there a vbs code that i can execute to get it?
This script shows the folder path where the script is located.
' FileName : Setup.vbs
With CreateObject("Shell.Application")
MsgBox .NameSpace(0).ParseName(WScript.ScriptFullName).Parent.Items.Item.Path
End With
I use the following script to copy AddIn to default AddIns folder.
' FileName : SetAddIn.vbs
Option Explicit
Const ssfAPPDATA = &H1A: Dim SA, DstF, SrcF, Ans
Ans = MsgBox("Copy AddIn to default AddIns folder", vbOKCancel)
If Ans <> vbOK Then WScript.Quit
Set SA = CreateObject("Shell.Application")
Set DstF = SA.NameSpace(ssfAPPDATA).ParseName("Microsoft").GetFolder
Set SrcF = SA.NameSpace(0).ParseName(WScript.ScriptFullName).Parent
Call CopyAddins(DstF, SrcF)
MsgBox "Completed."
'
Sub CopyAddins(Dst, Src)
Dim aItem
For Each aItem In Src.Items
If aItem.IsFolder Then
Call CopyAddins(Dst, aItem.GetFolder)' recursive call
Else
Select Case LCase(Right(aItem.Name, 4))
Case ".xla", ".ppa"
Dst.ParseName("AddIns").GetFolder.CopyHere aItem, 16
Case ".dot"
Dst.ParseName("Templates").GetFolder.CopyHere aItem, 16
End Select
End If
Next
End Sub