-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEXCEL_CHART_PICTURE_LIBR.bas
executable file
·62 lines (48 loc) · 2.26 KB
/
EXCEL_CHART_PICTURE_LIBR.bas
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
52
53
54
55
56
57
58
59
60
61
62
Attribute VB_Name = "EXCEL_CHART_PICTURE_LIBR"
'--------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------
Option Explicit 'Requires that all variables to be declared explicitly.
Option Base 1 'The "Option Base" statement allows to specify 0 or 1 as the
'default first index of arrays.
'--------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------
'************************************************************************************
'************************************************************************************
'FUNCTION : CHART_SNAPSHOT_FUNC
'DESCRIPTION : TAKE A PICTURE OF A CHART
'LIBRARY : EXCEL_CHART
'GROUP : PICTURE
'ID : 001
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_CHART_SNAPSHOT_FUNC(ByRef CHART_OBJ As Excel.Chart, _
ByRef DST_RNG As Excel.Range)
On Error GoTo ERROR_LABEL
EXCEL_CHART_SNAPSHOT_FUNC = False
CHART_OBJ.CopyPicture Appearance:=xlScreen, Format:=xlPicture
DST_RNG.Activate
DST_RNG.Worksheet.Paste
EXCEL_CHART_SNAPSHOT_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_CHART_SNAPSHOT_FUNC = False
End Function
Function EXCEL_CHART_COPY_PASTE_IMAGE_FUNC(ByRef IMAGE_OBJ As Image, _
ByRef CHART_OBJ As Excel.Chart)
Dim k As Long 'lPicType
On Error GoTo ERROR_LABEL
EXCEL_CHART_COPY_PASTE_IMAGE_FUNC = False
'Do we want a metafile or a bitmap?
'If doing a 1 to 1 copy, xlBitmap will give a 'truer' rendition.
'If scaling the image, xlPicture will give better results
k = xlPicture
'Update the chart type and copy it to the clipboard, as seen on screen
CHART_OBJ.CopyPicture xlScreen, k, xlScreen
'Paste the picture from the clipboard into our image control
Set IMAGE_OBJ.Picture = PastePicture(k)
EXCEL_CHART_COPY_PASTE_IMAGE_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_CHART_COPY_PASTE_IMAGE_FUNC = False
End Function