vb连接excel:如何实现VB和EXCEL的无缝连接来源: 发布时间:星期五, 2008年12月26日 浏览:254次 评论:0
VB是常用
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() VB本身提自动化功能可以读写EXCEL表 ![]() 1、在工程中引用Microsoft Excel类型库: 从"工程"菜单中选择"引用"栏;选择Microsoft Excel 9.0 Object Library(EXCEL2000) ![]() ![]() ![]() 2、在通用对象 ![]() Dim xlApp As Excel.Application Dim xlBook As Excel.WorkBook Dim xlSheet As Excel.Worksheet 3、在 ![]() Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象 Set xlBook = xlApp.Workbooks.Open("文件名") '打开已经存在 ![]() xlApp.Visible = True '设置EXCEL对象可见(或不可见) Set xlSheet = xlBook.Worksheets("表名") '设置活动工作表 xlSheet.Cells(row, col) =值 '给单元格(row,col)赋值 xlSheet.Pr ![]() xlBook.Close (True) '关闭工作簿 xlApp.Quit '结束EXCEL对象 Set xlApp = Nothing '释放xlApp对象 xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL启动宏 xlBook.RunAutoMacros (xlAutoClose) '运行EXCEL关闭宏 4、在运用以上VB命令操作EXCEL表时 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 2、 EXCEL ![]() EXCEL提供 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 0
相关文章
读者评论发表评论 |