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
| Option Compare Database
Option Explicit
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
Public Enum TypeOuverture
imprimer = 1
ouvrir = 2
End Enum
Public Sub OuvrirDocument(strCheminFichier As String, intTypeOuverture As TypeOuverture)
'--------------------------------------------------------------------------------------------
' Projet : Interface Windows
' Auteurs : Romain Puyfoulhoux - http://access.developpez.com
' Christophe Warin (Tofalu) - http://access.developpez.com
' pour la gestion des erreurs
' Version / Date : 1.0 / 01.01.2008
' Révision / Date : -
' Commentaires : Permet d'ouvrir un fichier sans déclarer l'application a utiliser
'
' Exemple d'appel OuvrirDocument ("C:\Projets Access\Exemple.doc")
'
' Lien : http://access.developpez.com/faq/?page=Automation#shellexecute
'--------------------------------------------------------------------------------------------
'Déclaration des variables
Dim strTypeOuverture As String
Dim strDescriptionErreur As String
'Action selon valeur de intTypeOuverture
If intTypeOuverture = 1 Then
strTypeOuverture = "print"
Else
strTypeOuverture = "open"
End If
'Select Case ShellExecute(0, "open", strCheminFichier, vbNullString, vbNullString, 1)
Select Case ShellExecute(0, strTypeOuverture, strCheminFichier, vbNullString, vbNullString, 1) |
Partager