Bonjour,

J'essaie d'utiliser un type lors d'une Sub (shellExecute en l'occurence).

Début de mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
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
 
    impression = 1
    ouverture = 2
 
End Enum
 
Public Sub OuvrirDocument(strCheminFichier As String, strTypeOuverture 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 strDescriptionErreur As String
 
    'Select Case ShellExecute(0, "open", strCheminFichier, vbNullString, vbNullString, 1)
    Select Case ShellExecute(0, strTypeOuverture, strCheminFichier, vbNullString, vbNullString, 1)
Le but étant bien entendu de passer le paramètre impression ou ouverture.

Lorsque je veux appeler ma sub, l'éditeur me propose bien mon Type, ça c'est ok, mais j'ai une erreur à la compilation : Attendu : =

Voici l'appel :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
OuvrirDocument("C:\Projets Access\Test.doc", ouverture)
Merci de votre aide.

Domi2