Use VBA or vbscript...Excel VBA macro would be better
- Paste the first image to a blank Excel sheet.
- Based on the height of the image calculate its range. For example, for a height of 100, it occupies range A1 to A50. Likewise calculate its column based on the width. Eg column would be H.
- Then paste the 2nd image after A50 ie; A51
- Calculate its range too. Lets assume your new range with both the images is upto A100 and columns based on width is H100.
- Your total new range including both the images is A1 to H100.
- Now you just need to convert this range into a picture. Use Excel VBAs CopyPicture function of any range in your case A1 to H100.
Below is the VBA function to do that.
Sub Export()
Dim oWs As Worksheet
Dim oRng As Range
Dim oChrtO As ChartObject
Dim lWidth As Long, lHeight As Long
Set oWs = ActiveSheet
Set oRng = oWs.Range("A1:H100")
oRng.CopyPicture xlScreen, xlPicture
lWidth = oRng.Width
lHeight = oRng.Height
Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)
oChrtO.Activate
With oChrtO.Chart
.Paste
.Export Filename:="C:\Test\outputsample.jpg", Filtername:="JPG"
End With
oChrtO.Delete
End Sub
Change the path and the Range will be dynamic based on above logic explained.
I have checked it and its working fine. Converts a given range to an image.
Note, this code is only to convert a range of Excel into a picture. For the rest of the code you can search and get it from the internet.