我在vb中调用了word程序,我想在word退出的时候强制保存。请各位大虾指教。谢谢。
解决方案 »
- 如果恢复excel文件???????????
- 用Adodc向access表中插入数据时提示“对象关闭时,操作不被允许”,但数据却已经插入数据库了,这是为什么呀?
- MSHFlexGrid问提!在线等!!!!!
- 2000下做的vb程序安装到xp后无法运行
- 在2000下如何通过代码改变自定义纸张的打印方向?
- 调试问题!!!
- 有没有在局域网中从98系统机器发送消息给2000系统
- 帮我检查一个DAO数据库连接查询程序(在线等)
- 请问如何在注册表中添加一项计划任务?
- 求教:在vb中怎样才能得到打印机当前的作业队列?
- 怎么在click事件中连接网页
- 部件中没有"Microsoft Data Bound Grid Control 5.0", 为什么?
Dim WithEvents wApp As Word.Application '增加word对象的事件
Dim WithEvents wDoc As Word.Document ''增加word文档的事件现在点代码窗靠的左边的下拉框看看,你会发现多了wApp,wDoc两项。你就可以象command一样操作他了。
Dim Document As Word.DocumentDim WithEvents wApp As Word.Application '增加word对象的事件
Dim WithEvents wDoc As Word.Document ''增加word文档的事件Private Sub Form_Load()Set appword = CreateObject("word.Application")
Set Document = appword.Documents.Add
appword.Visible = True
End Sub
Private Sub wApp_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean)
Label1.Caption = "sdasdf"
End SubPrivate Sub wApp_Quit()
Label1.Caption = "sdasdf"
End SubPrivate Sub wDoc_Close()Label1.Caption = "sdasdf"End Sub
我将代贴出来,请大虾帮帮忙啊,为什么word的退出事件没有截获到啊?
这样就好了,我用过的
Dim WithEvents wApp As Word.Application '增加word对象的事件
Dim WithEvents wDoc As Word.Document ''增加word文档的事件Private Sub Form_Load()
Set wApp = CreateObject("word.Application")
Set wDoc = wApp.Documents.Add
wApp.Visible = True
End Sub
Private Sub wApp_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean)
Label1.Caption = "sdasdf"
End SubPrivate Sub wApp_Quit()
Label1.Caption = "sdasdf"
End SubPrivate Sub wDoc_Close()Label1.Caption = "sdasdf"End Sub
Dim appword As Word.Application
Dim Document As Word.DocumentDim WithEvents wApp As Word.Application '增加word對象的事件
Dim WithEvents wDoc As Word.Document ''增加word文件的事件Const strDocpath = "\\gcecnsr01\software\public\Customer_Spec\General Spec\S-118.doc"Private Sub Form_Load()Set wApp = CreateObject("word.Application")Set wDoc = wApp.Documents.Open(strDocpath)
wApp.Visible = True
End Sub
Private Sub wApp_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean)
Label1.Caption = "before Close"With wApp
.Documents.Close SaveChanges:=wdDoNotSaveChanges
.Quit
End With
End SubPrivate Sub wApp_Quit()
Label1.Caption = "App_quit"
End SubPrivate Sub wDoc_Close()Label1.Caption = "Doc Close"End Sub
Set wApp = CreateObject("word.Application")此处出错了。
我用的是ms 10.0 word object library.