VB的OLE控件引用EXCEL后如何保存EXCEL? 10
2个回答
展开全部
希望能帮到你
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object 'Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
xlApp.Visible = False
Set xlSheet = xlBook.Worksheets(1)
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(App.Path & "/test.xls") '打开已经存在的test.xls工件簿文件
Set xlSheet = xlBook.Worksheets(1) '设置活动表
.......
.......
xlSheet.SaveAs App.Path & "/test.xls" '保存文件
xlBook.Close
xlApp.Quit
Set xlApp = Nothing
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object 'Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
xlApp.Visible = False
Set xlSheet = xlBook.Worksheets(1)
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(App.Path & "/test.xls") '打开已经存在的test.xls工件簿文件
Set xlSheet = xlBook.Worksheets(1) '设置活动表
.......
.......
xlSheet.SaveAs App.Path & "/test.xls" '保存文件
xlBook.Close
xlApp.Quit
Set xlApp = Nothing
展开全部
直接使用excel
Dim x As Excel.Application
Dim xbook As Excel.Workbook
Dim xsheet As Excel.Worksheet
Set x = CreateObject("excel.application")
s_path = App.Path & "\test.xls"
Set xbook = x.Workbooks.Open(s_path)
Set xsheet = x.Worksheets("sheet1")
打字不易,如满意,望采纳。
Dim x As Excel.Application
Dim xbook As Excel.Workbook
Dim xsheet As Excel.Worksheet
Set x = CreateObject("excel.application")
s_path = App.Path & "\test.xls"
Set xbook = x.Workbooks.Open(s_path)
Set xsheet = x.Worksheets("sheet1")
打字不易,如满意,望采纳。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询