INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to know when an Ole Object can be Destroyed - Word Doc

How to know when an Ole Object can be Destroyed - Word Doc

(OP)
PB 12.6
I have an OLE Object being used to open a Word Document for the user to view. The issue that I have is that I do not know when or if the user closes the session of Word that gets launched so am not sure how to handle Destroying the object.

I appreciate any comments, examples, recommendations on how to handle this situation.
Thanks,
Bill

----------------------------
code snippet
----------------------------
at this point, the word document file name is stored in string variable ls_doc_file

// Declare local Ole Word Doc Object
OLEObject ole_obj_word_doc

// instantiate the ole object
ole_obj_word_doc = CREATE oleobject

// connect to WORD app
li_retval = ole_obj_word_doc.ConnectToNewObject("word.application")
IF li_retval < 0 THEN
DESTROY ole_obj_word_doc
MessageBox("Connecting to COM Object Failed", &
"Error: " + String(li_retval))
Return
END IF

// open the file
ole_obj_word_doc.documents.open(ls_doc_file)

// Make the object visible and display the
ole_obj_word_doc.Application.Visible = True


// *********************************************
// These are commented out because I don't know
// when the user closes the file.
// *********************************************
// shut down the server
//??ole_obj_word_doc.quit()
// destroy the object
//??DESTROY ole_obj_word_doc
// *********************************************

RE: How to know when an Ole Object can be Destroyed - Word Doc

You won't ever know when/if the user closes the word doc. About the only thing you can do is to issue a DisconnectObject command when the window/application closes. I wouldn't worry about using DESTROY as the garbage collection will take care of this.

Matt

"Nature forges everything on the anvil of time"
www.anvil-of-time.com

RE: How to know when an Ole Object can be Destroyed - Word Doc

(OP)
Thanks Matt

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close