Alpha Video Training
Results 1 to 15 of 15

Thread: OLE with WORD leaves Word OPEN

  1. #1
    Member richkerr's Avatar
    Real Name
    Rich Kerr
    Join Date
    Mar 2003
    Location
    Chicago, IL
    Posts
    93

    Default OLE with WORD leaves Word OPEN

    Anyone:

    After starting an OLE session to create a word document and sending text to it from my database, an instance of WINWORD.exe is still in memory, even after closing word.

    Is there an OLE command to "disconnect" the opening of the connection to Word from Alpha, so that when my user closes the word document, Word is really closed?

    Thanks in advance...

    Rich Kerr

  2. #2
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default RE: OLE with WORD leaves Word OPEN

    try .Close() or simply deleting the variable you were using.

  3. #3
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default RE: OLE with WORD leaves Word OPEN

    I just tried it on my machine and there is no close() method, and deleting the variable has no effect. Not sure if this is a bug or not, but we'll take a look at it.

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: OLE with WORD leaves Word OPEN

    When I use the construction

    WB = ole.Create("Word.Basic")

    a final

    WB.Quit()

    closes Word in memory.

  5. #5
    Member richkerr's Avatar
    Real Name
    Rich Kerr
    Join Date
    Mar 2003
    Location
    Chicago, IL
    Posts
    93

    Default RE: OLE with WORD leaves Word OPEN

    Stan/Aaron:

    Will try the .quit() method... thanks a million...

    Rich

  6. #6
    Member Elke's Avatar
    Real Name
    Elke Barghoorn
    Join Date
    Sep 2000
    Location
    New York
    Posts
    339

    Default RE: OLE with WORD leaves Word OPEN

    Rich,

    Does quit() work for you?

    Thanks Elke

  7. #7
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default RE: OLE with WORD leaves Word OPEN

    For me it works in excel.
    also with help from Stan.

    xlapp.DisplayAlerts = .F. 'suppres messages
    xlApp.Workbooks.Close() 'close document in excel
    xlapp.DisplayAlerts = .T. 'toggle messages on
    xlApp.Quit() 'close the application

    Ton

  8. #8
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default RE: OLE with WORD leaves Word OPEN

    The clever developer would have found this information in the help file at OLE.GetObject().

  9. #9
    Member richkerr's Avatar
    Real Name
    Rich Kerr
    Join Date
    Mar 2003
    Location
    Chicago, IL
    Posts
    93

    Default RE: OLE with WORD leaves Word OPEN

    Hey Guys:

    Thanks for each of your responses. The problem has a second component that I did not notice before... the line in my script that creates the (gets) the word object, actually creates two instances of MS Word. One has the current username, the second instance has the "SYSTEM" username. This is visible in the Windows Task Manager, Processes list.

    The quit command closes the instance of WINWORD.EXE that has the current user's naame as the "User Name" but the instance listed with the "SYSTEM" user name does not close... has any one else seen this?

    newWord = ole.create("Word.Application") 'two instances of WINWORD.EXE appear in the processes list of the Task Manager at this point

    newWord.Visible = .T.
    newDocument = newWord.Documents.Add()
    newDocument.SaveAs("C:\drat.doc")
    newword.quit() 'Only the first instance of WINWORD.exe closes here... one remains open...

    Any thoughts?

    TIA

    Rich Kerr

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: OLE with WORD leaves Word OPEN

    Just tried what you describe and I only get one instance of winword.exe.

  11. #11
    Member Elke's Avatar
    Real Name
    Elke Barghoorn
    Join Date
    Sep 2000
    Location
    New York
    Posts
    339

    Default RE: OLE with WORD leaves Word OPEN

    Rich,

    I get the same results, Word is still open.

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: OLE with WORD leaves Word OPEN

    What happens if you change

    newWord = ole.create("Word.Application")

    to

    newWord = ole.getobject("Word.Application")

  13. #13
    Member Elke's Avatar
    Real Name
    Elke Barghoorn
    Join Date
    Sep 2000
    Location
    New York
    Posts
    339

    Default RE: OLE with WORD leaves Word OPEN

    Changing it to newWord = ole.getobject("","Word.Application")works.

  14. #14
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: OLE with WORD leaves Word OPEN

    Would tend to indicate that an instance of word was open (due to ?) from some prior activity.

  15. #15
    Member richkerr's Avatar
    Real Name
    Rich Kerr
    Join Date
    Mar 2003
    Location
    Chicago, IL
    Posts
    93

    Default RE: OLE with WORD leaves Word OPEN

    Gentlemen:

    Your wisdom knows no bounds! The getobject variant worked like a charm. Only one instance of WINDWORD.exe is created, and then the .quit() function closes it cleanly.

    Thanks a million for your advice. The create function routinely creates two instances of word. I verified that there is no previous instance of it, before running my script, step by step in the interactive window.

    Thanks again!!!

    Rich Kerr

Similar Threads

  1. A5 Help in PDF or Word
    By Mantford in forum Alpha Five Version 5
    Replies: 9
    Last Post: 08-30-2004, 03:15 PM
  2. Open Word Doc with Switches
    By Elke in forum Alpha Five Version 5
    Replies: 3
    Last Post: 05-11-2004, 05:26 AM
  3. The B word again
    By scottly in forum Alpha Five Version 5
    Replies: 3
    Last Post: 09-15-2003, 05:58 PM
  4. check for open instance of word documents
    By martinwcole in forum Code Archive
    Replies: 0
    Last Post: 06-28-2003, 07:10 AM
  5. OLE Automation Does Not Open Word
    By Gary Smith in forum Alpha Five Version 5
    Replies: 1
    Last Post: 05-07-2003, 06:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •