高分:Excel图表写入Word的VBA代码

来源:百度知道 编辑:UC知道 时间:2024/05/25 17:37:32
目的:在EXCEL工作表中设置一个按钮,单击就可以把EXCEL里的图表写入WORD中。
我想把Excel工作表中数据生成的图表写入到指定Word或新建Word中,以图片格式复制过去也行,请把VBA代码写一下。
只要写复制EXCEL图表到WORD这一段就好了(创建WORD及复制单元格的内容我已经搞定了,图表这一块不会,初学VBA,很多地方不懂)

Private Sub CommandButton1_Click()

'VBA工程中点工具下的引用,添加引用:Micrsoft Word 9.0 Object Library

    On Error Resume Next

    Dim waSolution As Word.Application

    Dim wdDocument As Word.Document

    Dim strPathA As String

    strPathA = "C:\1.doc"  '事先建好的指定word文档,用于保存

 

   ' Macro1 Macro

' 宏由 小路工作室 录制,时间: 2009-9-23

'

'

    ActiveSheet.ChartObjects("图表 2").Activate

    ActiveChart.ChartArea.Select

    ActiveChart.Axes(xlValue).MajorGridlines.Select

    ActiveChart.PlotArea.Select

    ActiveCh