vb调用excel的问题

quickman 2002-03-15 04:47:47
我在一个窗体的某个模块内定义了Excel.Application对象变量来生成excel表,
模块结束时调用了quit方法,然后设变量为nothing,
但任务管理器内还有excel进程,
只有把主程序关掉后该excel进程才消失,
请问有什么办法在程序内把它结束掉?
...全文
24 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
dingfuhao 2002-03-20
  • 打赏
  • 举报
回复
你shell 了一个excel文件
在你的进程列表中应该有一个excel.exe进程

quickman 2002-03-20
  • 打赏
  • 举报
回复
其他地方有点莫名其妙的小错误,
现在好了,谢谢各位
quickman 2002-03-20
  • 打赏
  • 举报
回复
不错,
我把shell的那个excel关掉后系统中还有一个excel,
正是那个xlApp没有关掉,
太奇怪了。。。。
quickman 2002-03-19
  • 打赏
  • 举报
回复

Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Dim strTemplateFile As String
Dim strTempFile As String
strTemplateFile = App.Path & "\sysdata\Template.xls"
strTempFile = App.Path & "\sysdata\Temp.xls"

FileCopy strTemplateFile, strTempFile

Set xlApp = CreateObject("Excel.Application")

Set xlBook = xlApp.Workbooks.Open(strTempFile)
' xlBook.Sheets.Delete
Set xlSheet = xlBook.Worksheets.Add

〈往exce里写数据〉。。。。。。。。。。。。。。

xlApp.Visible = True '显示表格
xlBook.Save '保存"
xlApp.Quit

Shell "D:\Program Files\Microsoft Office\Office\excel " & strTempFile

Set xlApp = Nothing '交还控制给Excel
Set xlBook = Nothing
Set xlSheet = Nothing
quickman 2002-03-19
  • 打赏
  • 举报
回复
Dim iCols As Integer '列数
Dim iRows As Integer '行数

Dim iCol As Integer
Dim strCol As String

Dim iRow As Integer
Dim strRange As String

Dim iColHeader As Integer '列头的起始位置
Dim iRowBegin As Integer '数据行的起始位置

Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Dim strTemplateFile As String
Dim strTempFile As String
strTemplateFile = App.Path & "\sysdata\Template.xls"
strTempFile = App.Path & "\sysdata\Temp.xls"

FileCopy strTemplateFile, strTempFile

Set xlApp = CreateObject("Excel.Application")

Set xlBook = xlApp.Workbooks.Open(strTempFile)
' xlBook.Sheets.Delete
Set xlSheet = xlBook.Worksheets.Add

iCols = Me.grdData.Cols


' xlApp.Visible = True '显示表格
xlBook.Save '保存"
xlApp.Quit

Shell "D:\Program Files\Microsoft Office\Office\excel " & strTempFile

Set xlApp = Nothing '交还控制给Excel
Set xlBook = Nothing
Set xlSheet = Nothing
aopiee 2002-03-19
  • 打赏
  • 举报
回复
看看excel有没有Add-Ins。
Lester_Zhang 2002-03-19
  • 打赏
  • 举报
回复
It works with me.
dingfuhao 2002-03-18
  • 打赏
  • 举报
回复
我以前也用过,也是这么做的,没出现这样的问题啊
donotbesilent 2002-03-18
  • 打赏
  • 举报
回复

给出代码来看看.
quickman 2002-03-15
  • 打赏
  • 举报
回复
确认!
你现在能试一下吗?
怪异!
dingfuhao 2002-03-15
  • 打赏
  • 举报
回复
按照你的方法应该可以的啊
确定两句话都执行了吗?

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧