Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. contorl on word save message prompt

contorl on word save message prompt

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    paykani
    wrote on last edited by
    #1

    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?

    J 2 Replies Last reply
    0
    • P paykani

      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?

      J Offline
      J Offline
      jonathan15
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • P paykani

        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?

        J Offline
        J Offline
        jonathan15
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • J jonathan15

          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

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          thaks a lot jonathan15.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups