I need to save pictures based single cells within a column which has Chinese characters in it as separate JPGs for inclusion in a Visual FoxPro report.
I have pored through various Stack Overflow questions, such as: Saving range as picture with Excel 2016 and Export pictures from excel file into jpg using VBA However, I'm relatively new at VBA, and I cannot figure out how to iterate through the table to make individual JPGs for each cell (and name them separately as well). Ideally, I would like to name them with the value of another column, but I can also live with naming then with the record number (i.e. 1.jpg, 2.jpg...). I tried making code from another post work (see below), but I haven't had any luck.
Sub makepic()
''' Set Range you want to export to file
Dim path As String
path = "C:\BP\BP2020\JPGs\"
Dim cntr As Integer
cntr = 1
Dim rgExp As Range
Dim CCntr As String
CString = "A1:B6"
Set rgExp = Range(CString)
For Each cell In rgExp
''' Copy range as picture onto Clipboard
rgExp.Cells.Item(cntr, 1).CopyPicture Appearance:=xlScreen, Format:=xlBitmap
''' Create an empty chart with exact size of range copied
With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
Width:=rgExp.Cells.Item(cntr, 1).Width, Height:=rgExp.Rows(cntr).Height)
.Name = "ChartVolumeMetricsDevEXPORT"
.Activate
End With
CCntr = rgExp.Cells.Item(cntr, 2)
cntr = cntr + 1
''' Paste into chart area, export to file, delete chart.
If CCntr <> "" Then
ActiveChart.Paste
ActiveSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Chart.Export (path + CCntr & ".jpg")
ActiveSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Delete
End If
Next cell
End Sub
The main error message I was getting concerned "shapes," however I'm not looking at copy pictures out, but to save text in each cell as pictures.
PS: I try to make my questions as succinct and readable as I can, but I am continually getting told I am not phrasing my questions right. This is evidently due to ignorance of the correct format. I have re-read the articles on posting and hope this one "passes muster." If not, I apologize.