I´m trying to export some range of cell as picture , I google it and I found code in VB but I stock to convert in AHK
Any Help would be nice
this is the file
Spoiler
codeCode: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
xl := ComObjCreate("Excel.Application")
xl.Visible := true
path = %A_ScriptDir%\A.xlsx
xl.Workbooks.Open(Path)
;xl.Worksheets("Excel_Gauge5").ChartObjects(6).Chart.Export( A_MyDocuments "\pic1.jpg" )
xl.Application.ScreenUpdating := False
xl.Set h1 := Sheets("Excel_Gauge5")
Set h2 = Sheets.Add
ruta = ThisWorkbook.Path & "\"
archivo = ruta & h1.[D1] & ".JPEG"
'
rango = "P1:U22"
'
With h1.Range(rango)
fi = .Cells(1, 1).Row
ff = .Rows.Count + fi - 1
ci = .Cells(1, 1).Column
cf = .Columns.Count + ci - 1
izq = .Cells(1, 1).Left
der = h1.Cells(1, cf + 1).Left
baj = .Cells(1, 1).Top
arr = h1.Cells(ff + 1, 1).Top
anc = der - izq
alt = arr - baj
End With
'
h1.Range(rango).CopyPicture
h2.Shapes.AddChart
With h2.ChartObjects(1)
.Width = anc
.Height = alt
.Chart.Paste
.Chart.Export archivo
.Delete
End With
Application.DisplayAlerts = False
h2.Delete
Application.DisplayAlerts = True
'
MsgBox "Celdas guardadas como imagen en el archivo: " & archivo, vbInformation, Date
End Sub
Thanks in advance