How to Convert Excel Cell Values Into Individual PNG Files

0 votes

This question was recently posed, however, it was closed for lack of effort. I spent enough time developing and studying this that I thought it was appropriate to post the answer (see below). Regarding PNG files by cell, there is no clear response to this query.

Example of layout

enter image description here

Desired Output Of Each Word.

enter image description here

Dec 19, 2022 in Others by Kithuzzz
• 38,000 points
492 views

1 answer to this question.

0 votes

This will:

  1. create a chart
  2. add an image to the chart
  3. Loop through each cell in the specified range that is also in the used range
  4. For cells that are not empty, it will update the image in the chart.
  5. Saves chart as a PNG file.

I got some help from SpreadSheetGuru as well as the legendary Tim Williams on this.

You'll need to update the Const to make your ranges.

Sub buildPNG()
    Const thePath As String = "C:\Users\SRide\OneDrive\Documents\Junk\" 'or wherever
    Const zWidth As Long = 600
    Const zLength As Long = 400
    Const theFontSize As Long = 96
    Const theRange As String = "A:A"
    
Dim WS As Worksheet, aCell As Range
    Set WS = ActiveSheet 'or whatever
    

Dim myChart As ChartObject
        Set myChart = WS.ChartObjects.Add(Left:=50, Width:=zWidth, Top:=50, Height:=zLength)
        
Dim myShape As Shape
    myChart.Activate
    Set myShape = ActiveChart.Shapes.AddTextbox(msoTextOrientationHorizontal, 1, 1, zWidth, zLength)
    
    With myChart.ShapeRange
      .Fill.Visible = msoFalse
      .Line.Visible = msoFalse
    End With

    With myShape.TextFrame
       
        .HorizontalAlignment = xlHAlignCenter
        .VerticalAlignment = xlVAlignCenter
        .Characters.Font.Size = theFontSize

        For Each aCell In Intersect(WS.UsedRange, WS.Range(theRange)).Cells
            If Not IsEmpty(aCell) Then
                .Characters.Text = aCell.Value2
                myChart.Chart.Export (thePath & aCell.Row & ".PNG")
            End If
        Next aCell
    End With
  
End Sub
answered Dec 19, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How to convert data from txt files to Excel files using python

Hi , there are few steps to ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
14,024 views
0 votes
1 answer

How to validate values entered in a multiline Excel cell?

Try: The formula in B1: =AND(BYROW(TEXTSPLIT(A1," "," ",1),LAMBDA(x,SUM((LEN(x)={3,7,4,4,5})ISNUMBER(-x)(MID(TAKE(x,-1),3,1)="."))))) Or, write a ...READ MORE

answered Jan 13, 2023 in Others by narikkadan
• 63,600 points
402 views
0 votes
1 answer

Excel VBA search based on cell values into folders and sub-folders to get the file path and data

This will create a listing of all ...READ MORE

answered Jan 19, 2023 in Others by narikkadan
• 63,600 points
2,075 views
0 votes
1 answer

How to divide data in excel into 4 columns whose sum is almost equal to 1/4 of the sum of all values/

5049 is the sum of all numbers, ...READ MORE

answered Feb 7, 2023 in Others by narikkadan
• 63,600 points
791 views
0 votes
1 answer

Convert a single png file to jpg in vba

Try this code: Sub ConveretPNGToJpg() ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 63,600 points
1,564 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,211 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,662 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
906 views
0 votes
1 answer

How to insert a picture into Excel at a specified cell position with VBA

Try this: With xlApp.ActiveSheet.Pictures.Insert(PicPath) With ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,600 points
2,486 views
0 votes
1 answer

How to Convert nested JSON into excel in nodejs

Try this: const filtered = attendanceData.map(obj => { ...READ MORE

answered Dec 28, 2022 in Others by narikkadan
• 63,600 points
2,912 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP