Sub test() '从"工程"菜单中选择"引用"栏;选择Microsoft Excel 9.0 Object Library(EXCEL2000) Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim 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).Value xlBook.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 = False Set 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 Sub