日期:2012-02-24  浏览次数:20478 次

Dim objShape As Word.InlineShape
        Dim objChart As Object
        Dim objDataSheet As Object
        Dim axis As Graph.Axis

        Dim strKey as string                       'bookmark的名称

       '首先要在word中嵌入一个graph,然后把这个graph添加一个bookMark(书签),名字就是strKey的内容

       objShape = mobjDoc.Bookmarks.Item(strKey).Range.InlineShapes.Item(1)
       objShape.OLEFormat.DoVerb(VerbIndex:=Word.WdOLEVerb.wdOLEVerbHide)
       objChart = objShape.OLEFormat.Object()

       '设置横轴的属性   

       axis = objChart.Axes(2, 1)

       '最小刻度
       axis.MinimumScale = 0

       '主要刻度单位
       axis.MajorUnit = 10

       '次要刻度单位
       axis.MinorUnit = 10

       '最大刻度
       axis.MaximumScale = 50

      '在graph的表格中填写内容

       objDataSheet = objChart.Application.DataSheet
       objDataSheet.Cells(1, 1) = "aa"

       '对表格进行更新

       objChart.Application.Update()

       '退出graph程序
       objChart.Application.QUIT()