CopyPicture Range Name在其他单元格之后

我正在尝试复制B列中的单元格,并在第1列中为其命名。我有可以工作的代码,除了它始终为图片赋予错误的名称。令人困惑的是,有时它可以完美地工作,而有时却不能。

我已尝试根据Copypicture命令的发布示例来整理例程。我将其粘贴在下面。

是的,我是VBScript的新手。要温柔。 ;-)

Sub makepic()
    Dim path As String
    path = "C:\BP\BP2020\JPGs\"
    Dim CLen As Integer
    Dim cntr As Integer
    cntr = 1
    Dim rgExp As Range
    Dim CCntr As String
    CString2 = "A1:A6"
    Set rgExp2 = Range(CString2)
    CString = "B1:B6"
    Set rgExp = Range(CString)

    For I = 1 To rgExp.Cells.Count Step 1
      CCntr = rgExp2.Cells(I).Value
      rgExp.Cells.Cells(I).Font.Size = 72
      rgExp.Cells.Cells(I).Copypicture Appearance:=xlScreen,Format:=xlBitmap
      rgExp.Cells.Cells(I).Font.Size = 14
      ''' Create an empty chart with exact size of range copied
      CLen = Len(rgExp.Cells.Cells(I).Value)
      CWidth = CLen * 85

      With activeSheet.ChartObjects.Add(Left:=1600,Top:=rgExp.Top,_
        Width:=CWidth,Height:=50)
        .Name = "ChartVolumeMetricsDevEXPORT"
        .activate
      End With

      ''' Paste into chart area,export to file,delete chart.
      If CCntr <> "" Then
        activeChart.Paste

        Selection.Name = "pastedPic"

        activeSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Chart.Export (path + CCntr & ".jpg")
        activeSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Delete
      End If
      cntr = cntr + 1
   Next
End Sub

同样,我希望-例如-单元格B1内容的图片具有A1内容的名称。我尝试使范围为A1:B4(例如),但是得到了8张图片。我最终决定尝试进行2个范围调整,但这都不起作用。

lwj1314520 回答:CopyPicture Range Name在其他单元格之后

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3155667.html

大家都在问