| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 830 人关注过本帖
标题:请看我的ACCESS数据转换为EXCEL的代码哪里错了
取消只看楼主 加入收藏
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
结帖率:84.62%
收藏
 问题点数:0 回复次数:3 
请看我的ACCESS数据转换为EXCEL的代码哪里错了

请看我的ACCESS数据转换为EXCEL的代码哪里错了?

怎么点击“转换”按钮时,怎么转换不起来呢?

我是转贴别人的代码,稍作修改而成!

“转换”按钮代码如下:

appdisk = Trim(App.Path)
If Right(appdisk, 1) <> "\" Then appdisk = appdisk & "\"
Dim lRow As Long
Dim sXLSPath As String
Dim MyExcel As New Excel.Application
Dim MyBook As Excel.Workbook
Dim MySheet As Excel.Worksheet
Dim s As String
Dim i As Integer
Dim j As Integer
Screen.MousePointer = 11
sXLSPath = appdisk & "gcjs.xls"
Open sXLSPath For Output As #1
Close #1
Set MyExcel = CreateObject("excel.application")
Set MyBook = MyExcel.Workbooks.Open(sXLSPath)
Set MySheet = MyExcel.ActiveSheet
MySheet.Range("A1:O1").Select
With MyExcel.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With

MySheet.Columns("A:C").NumberFormat = "0_ "
MySheet.Columns(1).ColumnWidth = 5
。。。
。。。
MySheet.Cells(1, 1) = "K(常数)"
MySheet.Cells(2, 1) = 100 。。。
。。。
For i = 2 To rst.Fields.Count
For j = 2 To rst.RecordCount
MySheet.Cells(j, i).Value = rst.Fields(i - 1).Value
Next j
Next i

具体请看附件!

谢谢!

MVKCMBSY.rar (24.85 KB) 请看我的ACCESS数据转换为EXCEL的代码哪里错了


搜索更多相关主题的帖子: EXCEL ACCESS 数据 代码 
2007-07-10 23:53
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
收藏
得分:0 
能具体详细点么?
2007-07-11 15:20
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
收藏
得分:0 
MDB里的数据怎么转换为XLS的却全是当前所输入的数据?前面的几个数据全部被刚刚输入的数据所替代了?
尽管数据个数是正确的!
2007-07-11 22:30
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
收藏
得分:0 

请看我刚刚修改的“转换”(Command4)控件的代码如下:

Private Sub Command4_Click()
appdisk = Trim(App.Path)
If Right(appdisk, 1) <> "\" Then appdisk = appdisk & "\"
Dim lRow As Long
Dim sXLSPath As String
Dim MyExcel As New Excel.Application
Dim MyBook As Excel.Workbook
Dim MySheet As Excel.Worksheet
Dim s As String
Dim i As Integer
Dim j As Integer
Screen.MousePointer = 11
sXLSPath = appdisk & "gcjs.xls"

Set MyExcel = CreateObject("excel.application")
Set MyBook = MyExcel.Workbooks.Open(sXLSPath)
Set MySheet = MyExcel.ActiveSheet
MySheet.Range("A1:O1").Select
With MyExcel.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
MyExcel.Visible = True


MySheet.Columns("A:C").NumberFormat = "0_ "
MySheet.Columns(1).ColumnWidth = 5
MySheet.Columns(2).ColumnWidth = 10
MySheet.Columns(3).ColumnWidth = 10
MySheet.Columns(4).ColumnWidth = 10
MySheet.Columns(5).ColumnWidth = 10
MySheet.Columns(6).ColumnWidth = 10
MySheet.Columns(7).ColumnWidth = 10
MySheet.Columns(8).ColumnWidth = 10
MySheet.Columns(9).ColumnWidth = 10
MySheet.Cells(1, 1) = "K(常数)"
MySheet.Cells(2, 1) = 100

MySheet.Cells(1, 2) = "度"
MySheet.Cells(1, 3) = "分"
MySheet.Cells(1, 4) = "秒"
MySheet.Cells(1, 5) = "上丝"
MySheet.Cells(1, 6) = "中丝"
MySheet.Cells(1, 7) = "下丝"
MySheet.Cells(1, 8) = "测距"
For i = 2 To rst.Fields.Count
For j = 2 To rst.RecordCount
MySheet.Cells(j, i).Value = rst.Fields(i - 1).Value
Next j
Next i
Screen.MousePointer = 0

End Sub

2007-07-11 22:33
快速回复:请看我的ACCESS数据转换为EXCEL的代码哪里错了
数据加载中...
 
   



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

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