contorl on word save message prompt
-
hi all I could Run word by VB6...for example user open an exiting file and make some changes on content of that .doc file when user close word u know this message appear : do u want to save the changes to "FileName.doc" ? yes/No ...now my problem:i want to control this user selected option (yes or no)in my program..i want to control that user click on yes or no? how can I take this control?
-
hi all I could Run word by VB6...for example user open an exiting file and make some changes on content of that .doc file when user close word u know this message appear : do u want to save the changes to "FileName.doc" ? yes/No ...now my problem:i want to control this user selected option (yes or no)in my program..i want to control that user click on yes or no? how can I take this control?
You cant really, but you dont actually need to. All you need to do is code in the before close event to pop up your own message box then close word from code and suppress Words one from showing (this is an argument in the close method i think). Try it yourself. If you have any problems i will try to get an example for you. Jon
-
hi all I could Run word by VB6...for example user open an exiting file and make some changes on content of that .doc file when user close word u know this message appear : do u want to save the changes to "FileName.doc" ? yes/No ...now my problem:i want to control this user selected option (yes or no)in my program..i want to control that user click on yes or no? how can I take this control?
OK. A simple example for you. All it does is replace words save box with my own.
Private WithEvents oword As Word.Application Private WithEvents odoc As Word.Document Private Sub Command1_Click() Set oword = New Word.Application oword.Visible = True Set odoc = oword.Documents.Open("yourfile.doc") End Sub Private Sub oword_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean) If MsgBox("Do you want to save this file?", vbYesNo, "Save") = vbYes Then oword.Activate ' not required if oword is not visible odoc.Save oword.Documents.Close 'If using word 2000 or below i think you need the argument here to not save changes. That will suppress words messagebox but this works fine with word 2003 oword.Quit Else oword.Activate oword.Documents.Close oword.Quit End If Set odoc = Nothing Set oword = Nothing End Sub
-
OK. A simple example for you. All it does is replace words save box with my own.
Private WithEvents oword As Word.Application Private WithEvents odoc As Word.Document Private Sub Command1_Click() Set oword = New Word.Application oword.Visible = True Set odoc = oword.Documents.Open("yourfile.doc") End Sub Private Sub oword_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean) If MsgBox("Do you want to save this file?", vbYesNo, "Save") = vbYes Then oword.Activate ' not required if oword is not visible odoc.Save oword.Documents.Close 'If using word 2000 or below i think you need the argument here to not save changes. That will suppress words messagebox but this works fine with word 2003 oword.Quit Else oword.Activate oword.Documents.Close oword.Quit End If Set odoc = Nothing Set oword = Nothing End Sub