Private Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (lpString As Any) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (lpString1 As Any, lpString2 As Any) As Long
Private Function GetCmd() As String
Dim lpCmd As Long
lpCmd = GetCommandLine()
GetCmd = Space$(lstrlen(ByVal lpCmd))
lstrcpy ByVal GetCmd, ByVal lpCmd
End Function
Private Sub Workbook_Open()
Dim macmdline As Variant
Dim monparam As Variant 'déclare une variable
Dim ListeParam As Variant
Dim i As Integer
macmdline = GetCmd 'affecte la valeur de la ligne de commande
If Not IsNull(macmdline) Then 'si la variable est nulle
If Len(macmdline) > 0 Then 'on s'assure qu'il y a eu une ligne de commande passée
If InStr(macmdline, "/cmd") > 0 Then
macmdline = Replace(macmdline, ThisWorkbook.FullName, "", , , vbTextCompare)
monparam = Split(macmdline, "/cmd")
ListeParam = Split(Mid(monparam(1), 2, Len(monparam(1)) - 3), "/")
For i = 0 To UBound(ListeParam)
Application.Run ListeParam(i)
Next i
End If
End If
End If
End Sub