Page 1 of 1

Chart excel to image JPG VBS

PostPosted: Mon Oct 16, 2017 4:55 pm
by alangonzalez91
Encontre algo para fabricar un gráfico de torta hasta el momento, usando microsoft excel, todavia falta armar la funcion, pero esto es lo que encontre lo comparto con ustedes, solo deben copiar en una funcion de vbscript

I found something to make a pie chart so far, using microsoft excel, I still need to set up the function, but this is what I found I share with you, you should only copy in a vbscript function

'---------------------------------

Dim oExl,oWrkbk,oWrkst,oMychart

Set oExl=CreateObject("Excel.Application")

With oExl

'EXCEL NO VISIBLE
.Visible=False

End With

Set oWrkbk=oExl.Workbooks.Add()
Set oWrkst=oWrkbk.Worksheets(1)

With oWrkst
'TITULO - TITLE
.Cells(1,2)="GRAFICO EN EXCEL PARA NEOBOOK"

'NOMBRE DE DATOS - DATA NAMES
.Cells(2,1)="Very Serious"
.Cells(3,1)="Serious"
.Cells(4,1)="Moderate"
.Cells(5,1)="Mild"

'VALORES - VALUES
.Cells(2,2)=22
.Cells(3,2)=12
.Cells(4,2)=42
.Cells(5,2)=35


End With

Set oRange=oWrkst.UsedRange
oRange.Select
Set oChart=oExl.charts
oChart.Add()
Set oMychart=oChart(1)
oMychart.Activate
oMychart.ChartType=5 ' ---> TIPO DE GRAFICO 5, 69. 68, 80, -4120, -4102 --->https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlcharttype-enumeration-excel
oMychart.ApplyDataLabels 5 '---> TIPO DE ETIQUETA 2 - 6

'ESTILOS - STYLE
oMychart.PlotArea.Fill.Visible=False
oMychart.PlotArea.Border.LineStyle=-4142
oMychart.SeriesCollection(1).DataLabels.Font.Size=15
oMychart.SeriesCollection(1).DataLabels.Font.ColorIndex=2

'COLOR DE FONDO - BACK COLOR
oMychart.ChartArea.Fill.Forecolor.SchemeColor=58 ' 1-58 (58 WHITE BLANCO)
oMychart.ChartArea.Fill.Backcolor.SchemeColor=32 ' 1-58 (58 WHITE BLANCO)
oMychart.ChartArea.Fill.TwoColorGradient 1,1

'ESTILOS DE TITULO - TITLE STYLES
oMychart.ChartTitle.Font.Size=20
oMychart.ChartTitle.Font.ColorIndex=4
'oWrkbk.Close
Set oExl=Nothing

'ALERTAS - ALERTS

If err.number<>0 then

Msgbox "error occurred while drawing..."
Msgbox err.Description

Else

Msgbox "Successfully drawn"

End If


' EXPORTADO A C:\ `RUIEBA TEST CHAR.JPG - EXPORTED
oMychart.Export "c:\PRUEBA TEST CHAR.jpg", "JPG"

'--------------------------------------

greetings and blessings

Re: Char excel to image JPG VBS

PostPosted: Mon Oct 16, 2017 7:34 pm
by virger
Muchas graciaas.
Lo revisare y te cuento.
Nos vemos en Rusia