Bonjour a tous,
Je cherche actuellement a lancer via VBA Excel une commande dans le shell cmd de WINDOWS.
Pour cela, j 'applique le code suivant:
Declaration de ShellExecute
Code : Sélectionner tout - Visualiser dans une fenêtre à part Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Partie du code ou je fais appel a shellExecute
J ai egalement essaye la chose suivante, histoire de tracer mon probleme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Dim Result, CommandString, fName, fCommandString fName = "C:\WINDOWS\system32\cmd.exe" ''"Index.html" fCommandString = "pdsdecode -p ""D:\Files Exeample\GPIT-F_Calibration_Report.PDS"" -d ""D:\Files Exeample\GPIT-F_Calibration_Report.txt""" MsgBox (fCommandString) Result = ShellExecute(hwnd, "Open", fName, fCommandString, 0, 1) If Result = 0 Then MsgBox ("Error while executing command")
Dans les deux cas, je me retrouve avec la fenetre du shell "system32\cmd.exe" ou apparait D:\Documents\.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Dim Result, CommandString, fName, fCommandString fName = "C:\WINDOWS\system32\cmd.exe" ''"Index.html" fCommandString = "cd .." ''"pdsdecode -p ""D:\Files Exeample\GPIT-F_Calibration_Report.PDS"" -d ""D:\Files Exeample\GPIT-F_Calibration_Report.txt""" MsgBox (fCommandString) Result = ShellExecute(hwnd, "Open", fName, fCommandString, 0, 1) If Result = 0 Then MsgBox ("Error while executing command")
Il semble donc que la fonction Shellexecute ne comprend pas mon parametrage fCommandString .
Quelqu'un a t'il une explication?
Merci de votre aide
Partager