Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Oleboundcontrol Not Releasing WINWORD.EXE process
Message
From
25/09/2002 11:49:49
 
 
To
25/09/2002 11:08:20
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00704007
Message ID:
00704305
Views:
21
>>>>Has anyone figured out how to close the WINWORD.EXE process that an oldboundcontrol object starts when it is assigned a control source?
>>>>
>>>>Here is the code I'm using:
>>>>
>>>> oform = CREATEOBJECT('form')
>>>> oform.ADDOBJECT('owordobject','oleboundcontrol')
>>>> oform.owordobject.CONTROLSOURCE = 'c_parent.contract'
>>>> oform.owordobject.SAVEAS(lcdir+lcfilename)
>>>> oform.owordobject.CONTROLSOURCE = ''
>>>> oform.REMOVEOBJECT('owordobject')
>>>> oform = ''
>>>> RELEASE oform
>>>>
>>>>REMOVOBJECT() and RELEASE oform do not remove the WINWORD.EXE process from the task manager. I thought maybe setting the CONTROLSOURCE to blank would do it but that didn't work either.
>>>>
>>>>HELP!!!!
>>>>
>>>>Trish
>>>
>>>Trish,
>>>
>>>
>>>WITH oForm.oWordObject
>>>.ActiveDocument.Close(0)
>>>.oWordObject.Quit()
>>>.oWordObject = .NULL.
>>>ENDWITH
>>>
>>>José
>>
>>
>>Every line produced an error.
>>
>>This is how I finally got it to work.
>>
>> oform = CREATEOBJECT('form')
>> oform.ADDOBJECT('owordobject','oleboundcontrol')
>> oform.owordobject.CONTROLSOURCE = 'c_parent.contract'
>> oform.owordobject.doverb(0)
>> oform.owordobject.SAVEAS(lcdir+lcfilename)
>> oform.REMOVEOBJECT('owordobject')
>> oform.destroy && not necessary
>> oform.release && not necessary
>> oform = ''
>> RELEASE oform
>>
>>You MUST have the DOVERB(0) AFTER assigning the CONTROLSOURCE. If you don't, it won't release WINDWORD.EXE.
>>
>>THIS IS NOT A PROBLEM UNDER Windows XP. My original source worked fine on XP. It seems to be a WINDOWS 2000 issue. It was happening on SP2 and SP3.
>>
>>Thanks.
>>Trish
>
>Okay...it worked under the debugger but not outside of it. The SAVEAS returns an error stating that another application is editing the document.
>
>Help!

Okay, leave it to me to figure out the screwest way to make this work. Here's the code.

oword = CREATEOBJECT('Word.Application')
IF TYPE('oword.visible') = 'U'
oword = CREATEOBJECT('Word.Application')
ENDIF

IF TYPE('oWord') = 'O'
oword.VISIBLE = .f.

*
* I have to open word first and let the
* oleboundcontrol use it or it will not
* remove the WINWORD.EXE process
*

oform = CREATEOBJECT('form')
oform.ADDOBJECT('owordobject','oleboundcontrol')
oform.owordobject.CONTROLSOURCE = 'c_parent.contract'
oform.owordobject.SAVEAS(lcdir+lcfilename)
oform.REMOVEOBJECT('owordobject')
oform.DESTROY
oform = ''
RELEASE oform

IF FILE(lcdir+lcfilename)
oword.documents.OPEN(lcdir+lcfilename)
oword.activedocument.pagesetup.PAPERSIZE = 2
*** check for bookmarks and update them
oword.activedocument.printout(.F.)
ENDIF
oword.QUIT(0)
ELSE
=MESSAGEBOX('Unable To Open Microsoft Word',48)
ENDIF
RELEASE oword
Previous
Reply
Map
View

Click here to load this message in the networking platform