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
| Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
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
Function Lien_rep_Valide(MonUrl As String) As Boolean
Lien_rep_Valide = Dir(MonUrl, vbDirectory) <> ""
End Function
Sub Capture_comment()
Dim FL As Worksheet, Limage As String, Shp As Shape
Dim chem_copie As String
On Error Resume Next
Set FL = Worksheets.Add
DoEvents
Range("A1").Select
ActiveSheet.Paste
DoEvents
Set Shp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
chem_copie = "C:\temp"
If Lien_rep_Valide(chem_copie) = False Then
MkDir (chem_copie)
End If
Limage = chem_copie & "\Limage.jpg"
Application.ScreenUpdating = False
With ActiveSheet.ChartObjects.Add(0, 0, Shp.Width, Shp.Height).Chart
.Paste
.Export Limage, "JPG"
End With
Application.DisplayAlerts = False
FL.Delete
Application.DisplayAlerts = False
Application.ScreenUpdating = True
With ActiveCell
.ClearComments
.AddComment
.Comment.Shape.Fill.UserPicture Limage
End With
End Sub |
Partager