Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel Range2Image
#1
I tried using CopyPicture but I don't know how scale (zoom) the image.

Can you help?
#2
Help to resize image in the clipboard?
#3
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?
#4
Do you need help to convert this code to QM?

Quote:Imagen.ChartArea.Width = Imagen.ChartArea.Width * 3
Imagen.ChartArea.Height = Imagen.ChartArea.Height * 3
#5
Yes; and Set Imagen = Rango7.Parent.ChartObjects.Add(33, 39, .Width, .Height).Chart
#6
Member function ExcelSheet.Range2Image
Code:
Copy      Help
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
Code:
Copy      Help
str pngFile="$temp$\excel.png"
ExcelSheet es.Init("Sheet1" 1)
es.Range2Image("A1:B2" pngFile)
run pngFile
#7
Thanks.


Forum Jump:


Users browsing this thread: 2 Guest(s)