1 pièce(s) jointe(s)
Exécution Macro VBA Excel via VBscript
Bonjour,
J'ai un script VBS qui permet de lancer une macro VBA Excel nommée "Macopie" du fichier FICTEST.xlsm ci-joint.
Mon script VBS marhe très bien quand quand je saisi en dure le chemin de macro :
Code:
1 2
|
ObjExcel.Application.Run "'C:\Users\toto\FICTEST.xlsm'!Module1.Macopie" |
Je souhaiterai cependant l'optimiser en rendant le chemin paramétrable, mais j'obtiens un message d'erreur:
Code:
1 2
|
Microsoft Excel ne peut accéder au fichier << "'C:\Users\toto\FICTEST.xlsm' >>. |
Voici le contenu de mon script VBS :
Code:
1 2 3 4 5 6 7
|
Dim ObjExcel
Path = WScript.Arguments.Item(0)
ObjExcel = CreateObject("Excel.Application")
ObjExcel.Application.Run chr(34) & "'" & Cstr(Path) & "FICTEST.xlsm'!Module1.Macopie" & chr(34)
Set ObjExcel = Nothing
WScript.Quit |
Pour lancer mon VBS je saisi la ligne de commande ci-dessous sur mon terminal :
cscript.exe Monvbs.vbs C:\Users\toto\
Auriez-vous des idées à me proposer ?
Par avance merci.