在vb中引用excel对象 菜单 "工程 "-> "引用-> "excel对象 " 然后: sub command_click() dim xapp as new excel.application dim xbook as new excel.workbook dim xsheet as new excel.worksheet
set xapp = new excel.application set xbook = xapp.workbooks.add set xsheet = xbook.worksheets(1) '第一页工作页 xapp.visible=true '使excel可见 ... '加入代码操作excel
xbook.close set xsheet = nothing '关闭对象 set xbook = nothing set xapp = nothing end sub