1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
Option Compare Database
Option Explicit
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2
Const SE_ERR_PNF = 3
Const SE_ERR_ACCESSDENIED = 5
Const SE_ERR_OOM = 8
Const SE_ERR_DLLNOTFOUND = 32
Const SE_ERR_SHARE = 26
Const SE_ERR_ASSOCINCOMPLETE = 27
Const SE_ERR_DDETIMEOUT = 28
Const SE_ERR_DDEFAIL = 29
Const SE_ERR_DDEBUSY = 30
Const SE_ERR_NOASSOC = 31
Const ERROR_BAD_FORMAT = 11
Public Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
StartDoc = ShellExecute(Scr_hDC, "open", DocName, _
"", "C:\", SW_SHOWNORMAL)
End Function
Public Function ErrorCheck(r As Long) As Integer
Dim msg As String
If r <= 32 Then
'There was an error
Select Case r
Case SE_ERR_FNF
msg = "Fichier non trouvé"
Case SE_ERR_PNF
msg = "Chemin non trouvé"
Case SE_ERR_ACCESSDENIED
msg = "Accès refusé"
Case SE_ERR_OOM
msg = "Mémoire insufisante"
Case SE_ERR_DLLNOTFOUND
msg = "DLL non trouvée"
Case SE_ERR_SHARE
msg = "Une violation de partage a eu lieu"
Case SE_ERR_ASSOCINCOMPLETE
msg = "Association de fichier incomplète ou invalide"
Case SE_ERR_DDETIMEOUT
msg = "Dépassement du temps d'attente pour DDE"
Case SE_ERR_DDEFAIL
msg = "Échec de transactiob DDE"
Case SE_ERR_DDEBUSY
msg = "DDE occupé"
Case SE_ERR_NOASSOC
msg = "Pas de programme associé à l'extention du fichier"
Case ERROR_BAD_FORMAT
msg = "Fichier EXE invalide ou erreur dans une image EXE"
Case Else
msg = "Erreur" & r & " inconnue"
End Select
MsgBox msg & " "
End If
End Function |
Partager