将图表从一个工作簿复制到另一个

Jor*_*ath 1 excel vba

我正在为 Excel 构建几个报告文件,它基本上将信息复制到另一个工作簿并保存。

我已经成功地复制了我的文本内容,但现在我需要能够复制图表,这是错误开始出现的时候......

这是我尝试过的:

ActiveSheet.Shapes(1).CopyPicture Appearance:=xlScreen, Format:=xlPicture
Workbooks("Relatorios.xlsm").Sheets("" & tb_nome.Text & "").Paste
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常,唯一的问题是我想要将图表放在单元格 E20 上,我尝试选择此单元格但出现错误,这是我尝试的:

Workbooks("Relatorios.xlsm").Sheets("" & tb_nome.Text & "").Range("E20").Select
Run Code Online (Sandbox Code Playgroud)

没有那条线,图表粘贴得很好,只是不是我想要的地方。

所以最终的代码看起来像:

ActiveSheet.Shapes(1).CopyPicture Appearance:=xlScreen, Format:=xlPicture
Workbooks("Relatorios.xlsm").Sheets("" & tb_nome.Text & "").Range("E20").Select
Workbooks("Relatorios.xlsm").Sheets("" & tb_nome.Text & "").Paste
Run Code Online (Sandbox Code Playgroud)

Tim*_*ams 5

    ActiveSheet.Shapes(1).CopyPicture Appearance:=xlScreen, Format:=xlPicture
    With Workbooks("Relatorios.xlsm").Sheets(tb_nome.Text)
        .Paste
        .Shapes(.Shapes.Count).Top = .Range("E20").Top
        .Shapes(.Shapes.Count).Left = .Range("E20").Left
    End With
Run Code Online (Sandbox Code Playgroud)