par Michael DELIQUE » 06 Nov 2007 à 09:08
- Code : Tout sélectionner
Public Sub ShellExecute_API(wPathFile As String)
' Permet de lancer des fichiers grace à leur extension ou des exécutables.
'Exemple : ShellExecute 0, "", "C:\Test.xls", "", "C:\", SW_SHOWNORMAL
%REM
'variableAPI pour la fonction
Const SW_SHOWNORMAL = 1
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
%END REM
'Déclaration Variable
Dim Lecteur As String
On Error Goto ErreurShellExecute_API
If isValideFile(wPathFile) = False Then
Error 9999, wPathFile+ " : fichier inexistant"
Exit Sub
End If
Lecteur = Strleft(wPathFile,"\")+"\"
ShellExecute 0, "", wPathFile, "",Lecteur, SW_SHOWNORMAL
Exit Sub
ErreurShellExecute_API:
Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
Exit Sub
End Sub
Cordialement
Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN