我想用VB调用EXCEL中数据画图 将图显示在另一个窗体上 谢谢了
2个回答
展开全部
以下为关键部分
'打开
Set sf1 = CreateObject("Excel.Application")
sf1.Workbooks.Add
Set sf2 = sf1.Workbooks(1)
Set sf3 = sf2.ActiveSheet
'作图
Range("A1:E5").Select
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:E5")
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveWindow.Visible = False
‘第二个图
Charts.Add
ActiveChart.ChartType = xl3DPieExploded
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:E5"), PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Windows("Book1").SmallScroll Down:=-9
ActiveWindow.Visible = False
'打开
Set sf1 = CreateObject("Excel.Application")
sf1.Workbooks.Add
Set sf2 = sf1.Workbooks(1)
Set sf3 = sf2.ActiveSheet
'作图
Range("A1:E5").Select
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:E5")
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveWindow.Visible = False
‘第二个图
Charts.Add
ActiveChart.ChartType = xl3DPieExploded
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:E5"), PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Windows("Book1").SmallScroll Down:=-9
ActiveWindow.Visible = False
追问
能不能写得更详细一点 最好有中文注解 谢谢了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询