| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 566 人关注过本帖
标题:代码出错了``````````
取消只看楼主 加入收藏
baiqie
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-1-19
收藏
 问题点数:0 回复次数:2 
代码出错了``````````

Private Sub Form_Load()
Dim objxl As New Excel.Application
Dim objxlbook As Excel.Workbook
Dim objxlsheet As Excel.Worksheet
Dim objxlchart As ChartObject
Dim strfile As String
Dim db As Database
Dim rs As String
Dim intloop As Integer
End Sub

Private Sub Recordsource_Click()
Set objxlbook = objxl.Workbooks.Add
Set objxlsheet = objxlbook.Worksheets("sheet1")
strfiloe = "C:\Report.xls"
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordset(Me.Reports)
intloop = 1
With objxlsheet
.Cells(intloop, 1) = rs.Fields(0).Name
.Cells(intloop, 2) = rs.Fields(1).Name
intloop = intloop + 1
Do
.Cells(intloop, 1) = rs.Fields(0)
.Cells(intloop, 2) = rs.Fields(1)
intloop = intloop + 1
rs.MoveNext
Loop Until rs.EOF
Set objxlchart = .ChartObjects.Add(156, 0, 0, 300)
objxlchart.Activate
With objxlchart.Chart
If Me.ChartTypeOption.Value = 1 Then
.ChartType = xl3DPieExploded
Else
.ChartType = xl3DColumn
End If
.ChartArea.Border.LineStyle = xlNone
.SeriesCollection.Add Source:=objxlbook.Sheets("sheet1").Range("A1:B" & intloop - 1)
.HasTitle = True
.ChartTitle.Text = Me.Reports
.Legend.Position = xlLegendPositionRight
.ApplyDataLabels xlDataLabelsShowValue
End With
.Cells(1, 1).Activate
End With
If Len(Dir(strfile)) > 0 Then Kill strfile
objxlboo.SaveAs strfile
objxlbook.Activate
objxl.Visible = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set objxlchart = Nothing
Set objxlsheet = Nothing
Set objxlbook = Nothing
objxl.Quit
Set objxl = Nothing
Set rs = Nothing
Set db = Nothing
End Sub

搜索更多相关主题的帖子: 代码 
2007-07-04 23:12
baiqie
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-1-19
收藏
得分:0 

不知道怎么传图片上来呀, 这是一个窗体,Reports为文本框
Recordsource是按钮

2007-07-04 23:19
baiqie
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-1-19
收藏
得分:0 
回复:(心中有剑)居然做的是3维的chart!但是感觉用....

我学ACCESS,没有学VB所以我也不知道那是什么东东

2007-07-09 19:18
快速回复:代码出错了``````````
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028359 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved