Comme alternative et complément à la sauvegarde d'une image sous forme de fichier .gif donnée par Cafeine (http://www.developpez.net/forums/sho...ighlight=image) j'ai récupérer ce code dans la FAQ VB6 pour réalisé la sauvegarde d'une copie d'écran et ai tenté de l'adapter à VBA.
Ma première question est : Est-ce possible ?
La seconde est : A quoi correspond en VBA Pic.hDC (en rouge)
(Pic étant ici le nom de l'image dans l'userform)
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
Private Declare Function BitBlt Lib "gdi32.dll" ( _
     ByVal hDestDC As Long, _
     ByVal x As Long, _
     ByVal y As Long, _
     ByVal nWidth As Long, _
     ByVal nHeight As Long, _
     ByVal hSrcDC As Long, _
     ByVal xSrc As Long, _
     ByVal ySrc As Long, _
     ByVal dwRop As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32.dll" () As Long

Private Declare Function GetDC Lib "user32.dll" ( _
     ByVal hwnd As Long) As Long

Private Const SRCCOPY As Long = &HCC0020
'______________________________________________________________________________

Private Declare Function FindWindowA Lib "user32" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  
Public Sub ScreenShot(Pic As Image)
'Dim Hdl As Long
    'Hdl = FindWindowA(vbNullString, Me.Caption)
    Pic.PictureSizeMode = 3
    Pic.Width = Me.Width
    Pic.Height = Me.Height
    Pic.Visible = False
    BitBlt Pic.hDC, 0&, 0&, Me.Width, Me.Width, GetDC(GetDesktopWindow()), 0&, 0&, SRCCOPY
    SavePicture Pic.Image, "C:\ScreenShot.bmp"
End Sub

Private Sub CommandButton1_Click()
    ScreenShot Pic
End Sub
Par avance, merci