BLACKHAYES
XLDnaute Impliqué
re-bonjour le forum,
Quel est le code pour transformer un usf en photo jpeg et l'enregistrer sur le bureau
Quel est le code pour transformer un usf en photo jpeg et l'enregistrer sur le bureau
re-bonjour le forum,
Quel est le code pour transformer un usf en photo jpeg et l'enregistrer sur le bureau
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function OpenClipboard& Lib "user32" (ByVal hwnd As Long)
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function GetClipboardData& Lib "user32" (ByVal wFormat%)
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function CloseClipboard& Lib "user32" ()
Private Declare Function CopyImage& Lib "user32" (ByVal handle&, ByVal un1&, ByVal n1&, ByVal n2&, ByVal un2&)
Private Declare Function IIDFromString Lib "ole32" (ByVal lpsz As String, ByRef lpiid As GUID) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32" (pPictDesc As PICTDESC, ByRef riid As GUID, ByVal fOwn As Long, ByRef ppvObj As IPicture) As Long
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(8) As Byte
End Type
Private Type PICTDESC
cbSize As Long
picType As Long
hImage As Long
End Type
Private iPic As IPicture
Private mode As Long
Sub SnapShot_USF_BMP()
Dim tIID As GUID, tPICTDEST As PICTDESC, Ret As Long
Dim hCopy As Long
Const IPictureIID = "{7BF80981-BF32-101A-8BBB-00AA00300CAB}"
keybd_event vbKeySnapshot, 1, 0&, 0&
DoEvents
OpenClipboard 0&
hCopy = CopyImage(GetClipboardData(2), 0, 0, 0, &H8)
CloseClipboard
If hCopy = 0 Then Exit Sub
Ret = IIDFromString(StrConv(IPictureIID, vbUnicode), tIID)
If Ret Then Exit Sub
With tPICTDEST
.cbSize = Len(tPICTDEST)
.picType = 1
.hImage = hCopy
End With
Ret = OleCreatePictureIndirect(tPICTDEST, tIID, 1, iPic)
If Ret Then Exit Sub
SavePicture iPic, ThisWorkbook.Path & "\" & "USF.bmp"
Set iPic = Nothing
End Sub
Private Sub CommandButton2_Click()
End Sub
Private Sub CommandButton2_Click()
SnapShot_USF_BMP
End Sub