主要是为了做个记录。
#include Once "Afx/AfxWin.inc" Dim As CObject xl = CreateObject("Excel.Application") Dim As CObject wkb = xl.Get("Workbooks") Dim As String xlspath=AfxGetExePath & IIf(Right(AfxGetExePath,1)="\","","\") Dim wb As CObject=wkb.Run("Open",xlspath & "1.xlsx") If wb.IsErr Then Print "错误" Else Print "正常" Dim As CObject shts = wb.Get("Sheets") Dim As CObject sht = shts.Get("Item" ,1) Dim As CObject chartObjects = sht.CallByName("ChartObjects",1) 'Print chartObjects.Get("Count") Dim As CObject chartObject = chartObjects.Run("Item",1) Print chartObject.Get("Name") chartObject.Run("Select") Dim As CObject chart = chartObject.Get("Chart") chart.Run("Export" ,xlspath & "chart1.jpg") Print "图表导出成功" chart.Clear chartObject.Clear chartObjects.Clear sht.Clear shts.Clear wb.Run("Close" ,vbFalse) wb.Clear wkb.Clear End If xl.Run("Quit") xl.Clear
标签:Dim,Run,Get,Clear,excel,vfb,图表,CObject,Print From: https://www.cnblogs.com/FanXiaoLei/p/16665206.html