tzkr.net
当前位置:首页 >> vB6.0怎么读取ExCEl表中内容 >>

vB6.0怎么读取ExCEl表中内容

private sub command1_click() dim xlbook as workbook dim xlapp as application dim xlsheet as worksheet set xlapp = createobject("excel.application") '隐藏方式打开excel set xlbook = xlapp.workbooks.open("d:\123.xls") '打开工作簿 set

private sub commandbutton1_click()workbooks.open filename:=thisworkbook.path & "\" & "abc.xls"range("a65500").end(xlup).offset(1, 0) = me.textbox1range("b65500").end(xlup).offset(1, 0) = me.textbox2range("c65500").end(xlup).

如果你插入的是窗体控件,很简单的.(activex控件比较麻烦,得用vba代码)右键点车间(1)控件,设置格式,最后一个标签“控制”,单元格链接处点到比如sheet1的g1,确定.在sheet2的a1输入 =if(sheet1!g1,"车间(1)","车间(2)")就可以了.

Private Sub Command1_Click() Dim Xlbook As Workbook Dim Xlapp As Application Dim Xlsheet As Worksheet Set Xlapp = CreateObject("Excel.Application") '隐藏方式打开excel Set Xlbook = Xlapp.Workbooks.Open("D:\123.xls") '打开工作

用commondialog可以解决选定打开.xls文件问题然后就是读取进去哈哈保存代码如下<br><br>'添加command控件一个msflexgrid控件一个<br>privatesubcommand1_click()<br>onerrorresumenext<br>dimfileaddasstring<br>commondialog1.

'以下演示了用 VB 打开excel, Dim ExlApp As Object Dim ExlBook As Object Dim ExlSheet As Object Set ExlApp = CreateObject("Excel.Application") '创建Excel的应用程序实例 Set ExlBook = ExlApp.Workbooks.Add '创建Excel的工作簿 Set

VB 读取5261Excel的内容4102:sub VB读取Excel的内容 () dim strData as string strdata=excel.Application.worksheets("你的工作1653表版").range("你的单元格权").valueend sub

把 If xlSheet.Cells(i, 1) > 0 Then 改为 If Val(xlSheet.Cells(i, 1)) > 0 试试

检查窗体上有没有名为Command1的按钮,名字必须为Command1.另外,看有没有引用OFFICE类

需要加载excel类库,然后写打开文件命令,之后就可以使用所有的VBA命令了,和在EXCEL里编写VBA代码是一样的!

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.tzkr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com