• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Word document and its Open/Closed status controlled via VB6

This is the code lines that work to open the word document.  
    Set objWordApp = CreateObject("Word.Application")
    Set objWordDoc = CreateObject("Word.Document")
   
    Set objWordDoc = objWordApp.Documents.Open(strMailMergeFilePath)
    objWordApp.Visible = True

After this lines I have the document opened and user can view it.  I would like to application to do some other stuff when user clicked the word document "closed' - that x - button in the right upper corner.

Is this possible to do?  Can the application see the status of the objWordDoc?

I
0
Aquarus
Asked:
Aquarus
1 Solution
 
SiddharthRoutCommented:
>>> Can the application see the status of the objWordDoc?

In your code trap errors. That should let you know if the user manually closes the word document.

Sid
0
 
greischCommented:
Create a class CWordDocument that can handle the document events :

Option Explicit

Public WithEvents Doc As Word.Document

'You can add properties and methods as you want'

Private Sub Doc_Close()
  ' Do what you want to be done when the doc is closed'
End Sub

Open in new window


Then in your code do :

Dim wordDoc as New CWordDocument
Set wordDoc.Doc = objWordApp.Documents.Open(strMailMergeFilePath)
objWordApp.Visible = True

Open in new window


When the document is closed by the user, Doc_Close in CWordDocument is called.
0
 
AquarusAuthor Commented:
Thank you ,

I am almost done here.

Can I programmatically set up the property of the word document so when the user closes it the word application does warn: Save or No or Cancel?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now