On May 20, 2014 10:22:38 PM EDT, Sytze de Boer <sytze.k...@gmail.com> wrote:
Sorry for this VFP post

I'm working with a very old application where the client absolutely
wanted
to create/edit their invoices per a Word file (doc)
So my app opens a word document with ShellExecute, and stores the
details
per routine
Append General rtfgen From &thefile Link
(where thefile may be something like INV4567.DOC)

I would probably do it differently now, but this never caused me any
problems until we upgraded some pc's at client site.
The messages we were getting all related to the
"document is in use by another application and cannot be accessed"

After much trial and error, it now seems
1  This only happens with 64 bit Windows
2  It only seems to happen after we print or preview the invoice

Using Task Manager, there are 1 or more instances of Word open on the pc
I thought of a quick fix.......
I created killword.prg as follows

PARAMETERS whatprg
lcProcess=UPPER(whatprg+".EXE")
lcComputer = "."
loWMIService = GETOBJECT("winmgmts:" +
"{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colProcessList = loWMIService.ExecQuery ("Select * from Win32_Process")

IF TYPE('colProcessList') = "O"
  FOR EACH loProcess IN colProcessList
     IF ALLTRIM(UPPER(loProcess.NAME)) == lcProcess OR
AT(lcProcess,UPPER(loProcess.NAME))>0
        loProcess.TERMINATE()
     ENDIF
  NEXT
ENDIF  && IF TYPE('colProcessList') = "O"
RELEASE colProcessList, loWMIService

But, it doesn't kill Word on a 64 bit pc
Can anyone help me, PLEASE

Are you certain the terminate line is being called?

-- 
Tracy

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/a6f91216-7684-4380-8fea-e8e73ee0e...@email.android.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to