我想用VB从EXCEL中读取数据?
怎么写程序?
不知道这样写对不对
Private Sub Command6_Click()
On Error GoTo Err1
Dim xing As String
Dim ming As String
Dim fei As String
Dim XLApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Text7.Text = "4582"
Set XLApp = CreateObject("Excel.Application")
xlSheet.Activate '激活工作表
If Dir("D:/temp/excel.bz") = "" Then '判断EXCEL是否打开
Set XLApp = CreateObject("Excel.Application") '创建EXCEL应用类
XLApp.Visible = True '设置EXCEL可见
xing = xlSheet.Cells(1, 5) '性别栏
fei = xlSheet.Cells(1, 7) '费用栏
ming = xlSheet.Cells(1, 3) '姓名栏
h = xlSheet.Cells(1, 10) '卡号
Debug.Print Len(xing), xing
Debug.Print Len(ming), ming
Debug.Print Len(fei), fei
xing = hanzhuan("张佳伟")
ming = hanzhuan(ming)
Text8.Text = "我"
xie(0) = xing & ming & fei & "00000000"
xie我想用VB从EXCEL中读取数据?
怎么写程序?
不知道这样写对不对
Private Sub Command6_Click()
On Error GoTo Err1
Dim xing As String
Dim ming As String
Dim fei As String
Dim XLApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Text7.Text = "4582"
Set XLApp = CreateObject("Excel.Application")
xlSheet.Activate '激活工作表
If Dir("D:/temp/excel.bz") = "" Then '判断EXCEL是否打开
Set XLApp = CreateObject("Excel.Application") '创建EXCEL应用类
XLApp.Visible = True '设置EXCEL可见
xing = xlSheet.Cells(1, 5) '性别栏
fei = xlSheet.Cells(1, 7) '费用栏
ming = xlSheet.Cells(1, 3) '姓名栏
h = xlSheet.Cells(1, 10) '卡号
Debug.Print Len(xing), xing
Debug.Print Len(ming), ming
Debug.Print Len(fei), fei
xing = hanzhuan("张佳伟")
ming = hanzhuan(ming)
Text8.Text = "我"
xie(0) = xing & ming & fei & "00000000"
xie(1) = yihuo(xie(0), 1)
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
Err1:
Set XLApp = Nothing
intTime = Val(Text3.Text)
Timer1.Interval = intTime
i = 33
j = 33
Timer1.Enabled = True
End Sub
从Set XLApp到Set XLApp = Nothing程序根本没有执行
在此区域外能执行 (在这一子程序里里边)
等待高手解决 (1) = yihuo(xie(0), 1)
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
Err1:
Set XLApp = Nothing
intTime = Val(Text3.Text)
Timer1.Interval = intTime
i = 33
j = 33
Timer1.Enabled = True
End Sub
从Set XLApp到Set XLApp = Nothing程序根本没有执行
在此区域外能执行 (在这一子程序里里边)
等待高手解决
我想用VB从EXCEL中读取数据?
最新推荐文章于 2025-06-19 16:41:10 发布