OVH Cloud OVH Cloud

Images ds formulaire

2 réponses
Avatar
Bernard
Bonjour,

Pour Access 2000.

Dans un formulaire,j'ai plusieurs images ins=E9r=E9es,=20
certaines au format bmp et d'autres au format jpg.

Je voudrais lorsque je clique sur une image pouvoir=20
d=E9finir le programme qui va l'ouvrir (MsPaint ou MS=20
Editor).

Actuellement les fichiers jpg s'ouvrent automatiquement=20
avec Ms Editor et les fichiers bmp avec Ms Paint.

Merci. A+

2 réponses

Avatar
Fred87
Bonjour

Mettre ce code dans un module

--------------------------------------------------------
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
Declare Function apiFindWindow Lib "user32"
Alias "FindWindowA" _
(ByVal lpclassname As Any, ByVal lpCaption As Any) As
Long

Global Const SW_SHOWNORMAL = 1
-----------------------------------------------------------

Sur le clic de l'image mettre :

---------------------------------------------------

Private Sub Image_Click(Cancel As Integer)

Dim hwnd
Dim StartDoc
Dim Chemin as string

hwnd = apiFindWindow("OPUSAPP", "0")

Chemin = "C:TOTO.bmp"
'Chemin de l'image ou du me.[nom du control image].picture

StartDoc = ShellExecute(hwnd, "open", Chemin, "", "C:",
SW_SHOWNORMAL)

End Sub
-----------------------------------------------------------


L'application associé a l'extenction du fichier s'ouvrira
et le fichier avec.

Cela marche bien sur pour tout type
d'extenction .xls .doc .gif .bmp .jpeg .wav etc .....

Bon courage

FRED87
Avatar
Fred87
Re bonjour

Autant pour moi a la deuxième lecture de ton post, je vois
que je ne t'ai pas donner ta réponse.

En fait sur le clic de l'image il suffit de tester
l'extenction du .picture du control image:
puis faire une commande shell de ce type:

Expl:
----------------------------------------------------------
-
Dim Retval
Dim Extenction As Variant

Extenction = Right(Me![Image].Picture, 3)

Select Case Extenction

Case "bmp", "jpg"

If MsgBox("Voulez vous ouvrir l'image avec Ms
Paint ?", vbYesNo) = vbYes Then
Retval = Shell("C:Program FilesMsPaint.exe " &
Me![Image].Picture, 1)
Exit Sub
End If

If MsgBox("Voulez vous ouvrir l'image avec Ms
editor ?", vbYesNo) = vbYes Then
Retval = Shell("C:Program FilesMsEditor.exe " &
Me![Image].Picture, 1)
Exit Sub
End If

Case Else
MsgBox ("Ce n'est pas un fichier image connu !!")

End Select

--------------------------------------------------------


Voila j'espère que cela repond à ta question

Fred87