【发布时间】:2021-10-02 16:45:42
【问题描述】:
【问题讨论】:
【问题讨论】:
这将:
我从SpreadSheetGuru 以及传奇的Tim Williams 那里得到了一些帮助。
您需要更新 Const 以创建您的范围。
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
【讨论】: