Excel Range2Image

Creating complex macros, dialogs, solving complex tasks, programming.

Excel Range2Image

Postby Lucas on Mon Jul 17, 2017 3:25 pm

I tried using CopyPicture but I don't know how scale (zoom) the image.

Can you help?
Lucas
Active Member
 
Posts: 833
Joined: Fri Apr 01, 2005 6:24 am
Location: Spain

Re: Excel Range2Image

Postby Gintaras on Mon Jul 17, 2017 3:38 pm

Help to resize image in the clipboard?
Gintaras
Site Admin
 
Posts: 10383
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Excel Range2Image

Postby Lucas on Mon Jul 17, 2017 3:41 pm

In any codes:

example:

Sub _Daily_Mail()

Dim Rango7 As Range
Dim Archivo As String
Dim Imagen As Chart
Dim Result As Boolean

Set Rango7 = Sheets("Summary").Range("P2:AI92") ' Summary
Sheets("Summary").Select

With Rango7
.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set Imagen = Rango7.Parent.ChartObjects.Add(33, 39, .Width, .Height).Chart
End With

Imagen.Paste
Imagen.ChartArea.Border.LineStyle = 0
Imagen.ChartArea.Width = Imagen.ChartArea.Width * 3
Imagen.ChartArea.Height = Imagen.ChartArea.Height * 3

Imagen.export "C:\Users\mely\Documents\Imagenes_POS\Informe1.png", filtername:="PNG"
Imagen.Parent.Delete
Set Imagen = Nothing

https://stackoverflow.com/questions/338 ... ank-images

How to use ChartArea.Width and ChartArea.Height to shrink the image?
Lucas
Active Member
 
Posts: 833
Joined: Fri Apr 01, 2005 6:24 am
Location: Spain

Re: Excel Range2Image

Postby Gintaras on Mon Jul 17, 2017 3:59 pm

Do you need help to convert this code to QM?

Imagen.ChartArea.Width = Imagen.ChartArea.Width * 3
Imagen.ChartArea.Height = Imagen.ChartArea.Height * 3
Gintaras
Site Admin
 
Posts: 10383
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Excel Range2Image

Postby Lucas on Mon Jul 17, 2017 4:03 pm

Yes; and Set Imagen = Rango7.Parent.ChartObjects.Add(33, 39, .Width, .Height).Chart
Lucas
Active Member
 
Posts: 833
Joined: Fri Apr 01, 2005 6:24 am
Location: Spain

Re: Excel Range2Image

Postby Gintaras on Mon Jul 17, 2017 6:07 pm

Member function ExcelSheet.Range2Image     ?
function $range $pngFile [double'scale]

Excel.Range r=_Range(range)

r.CopyPicture(Excel.xlScreen Excel.xlPicture)
Excel.Chart im = ws.ChartObjects.Add(33, 39, r.Width, r.Height).Chart

im.Paste
im.ChartArea.Border.LineStyle = 0
if scale>0 and scale!=1.0
,im.ChartArea.Width = im.ChartArea.Width * scale
,im.ChartArea.Height = im.ChartArea.Height * scale
,
,;Scaling fails. DOn't know how to make it work.
,;Error (RT) in <open ":14130: /397">ExcelSheet.Range2Image: 0x80020009, Exception occurred.
,;0x3EC, Unable to set the Width property of the ChartArea class. <help #IDP_ERR>?

im.export(_s.expandpath(pngFile) "PNG")
im.Parent.Delete



Macro Macro2865     ?
str pngFile="$temp$\excel.png"
ExcelSheet es.Init("Sheet1" 1)
es.Range2Image("A1:B2" pngFile)
run pngFile

Gintaras
Site Admin
 
Posts: 10383
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Excel Range2Image

Postby Lucas on Mon Jul 17, 2017 6:17 pm

Thanks.
Lucas
Active Member
 
Posts: 833
Joined: Fri Apr 01, 2005 6:24 am
Location: Spain


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests