Sub test()'从"工程"菜单中选择"引用"栏;选择Microsoft Excel 9.0 Object Library(EXCEL2000)Dim xlApp As Excel.ApplicationDim xlBook As Excel.WorkbookDim xlSheet As Excel.Worksheet'---------------------操作现有的excel---------------------Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象Set xlBook = xlApp.Workbooks.Open("c:/sheep.xls") '打开已经存在的EXCEL工件簿文件xlApp.Visible = True '设置EXCEL对象可见(或不可见)Set xlSheet = xlBook.Worksheets("Sheet1") '设置活动工作表xlSheet.Cells(1, 2) = "sssss" '给单元格(row,col)赋值s = xlSheet.Cells(2, 2).ValuexlBook.Close (True) '关闭工作簿xlApp.Quit '结束EXCEL对象Set xlApp = Nothing '释放xlApp对象'xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL启动宏'xlBook.RunAutoMacros (xlAutoClose) '运行EXCEL关闭宏'------------------------end------------------------------'---------------------导出新的excel-------------------------Set xlApp = CreateObject("Excel.Application")Set xlBook = xlApp.Workbooks.Add '创建工作簿xlApp.Visible = FalseSet xlSheet = xlBook.Worksheets(1) '创建工作表xlSheet.Name = "表一" '表名xlSheet.Cells(1, 1) = "shshshs"xlSheet.SaveAs "c:/销售.xls"'xlSheet.SaveAs App.Path & "/销售/" & mystr & ".xls"xlBook.Close (True) '关闭工作簿xlApp.Quit '结束EXCEL对象Set xlApp = Nothing '释放xlApp对象'-------------------------end-----------------------------End SubSub test()'从"工程"菜单中选择"引用"栏;选择Microsoft Excel 9. 你的当前访问异常,请进行认证后继续阅读剩余内容。 提交