cancel
Showing results for
Did you mean:
Frequent Visitor

## How to merge small images (png) into a combine images (png)

As topic, I extract images (png) from a PDF file.

then i need to merge some of them in 2 different images,

1 ACCEPTED SOLUTION

Accepted Solutions
Multi Super User

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.

3 REPLIES 3
Super User

Try automating this process:

https://products.aspose.app/words/merger/png

----
If my post has answered your question, please thumbs up and mark this post as a solution.

I also offer paid consulting services. If you would like to discuss this option, please feel free to DM me and we can set up a time to join a Zoom call and fix any issues you are having.
Frequent Visitor

Can merge PNGs action done by script/code? this is a good way and it works.

However, my PAD machine is network restricted control by group policy, it does not allow me to access external website and upload files....

Multi Super User

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.

Announcements

#### Celebrating the May Super User of the Month: Laurens Martens

@LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!