View Full Version : Word and access instances still running after close.
Movian
05-09-2012, 10:35 AM
Hey,
I have discovered a problem some of our clients are having where by after a word document is closed or our access database is closed. There is still a process running for it in the task manager even though it can't be viewed on the desktop.
This can cause issues when our users try to edit word documents that are still in use by these running processes. And can cause major system slow downs when they have 5 or 6 access processes running that they can't see.
What i would like to do is try and figure out a way to loop through all open instances of these programs (MSACCESS.exe and MSWord.exe) check to see if they are visible or not and then end the process if it is not, or if there are processes detected. Ask the user if they wish to end them (that parts easy).
What i am after is a spring board to get me started on this project. I am familiar with starting instances of programs (we create instances of word all the time to generate reports). However looping through existing instances of applications is not somthing i am familiar with and my initial searches have yielded little fruit. If anyone has any suggestions on where to look or any sample code to get me going i would apriciate it!
Thanks in advance
geekgirlau
05-09-2012, 06:24 PM
You say you create instances of Word all the time - are you also closing them? I'd check that first.
Movian
05-09-2012, 06:46 PM
Once the instances are created the system programaticly goes through all bookmarks in the document then when its finished the instance is made visible. and the user is able to edit the document and close it themselves, you raised a good point but one that I can say for certain is not the problem, also it would not explain the issues with the same problem with the database where closing the database yields the same result with an instance still running in the back ground.
I have had this same problem running office apllications completly seperatly from our database. Some times they just don't seem to close properly.... Excell, word and access all apear to do this.
geekgirlau
05-09-2012, 07:28 PM
Are you setting the object to Nothing when you're done with it?
Movian
05-10-2012, 06:52 AM
Yes,
The instances that are created when done are set to visible to the user and then all programing interfaces are closed and or set to nothing as needed. The user edits the document, saves then closes word. HOWEVER sometimes (not every time) some times the word process will remain open after the user tells word to close. As i mentioned the MSACCess.exe process sometimes remains running after they close our database too. I don't believe there is a programing issue that is causing this as i have seen similar problems on machines not running our system.... I would be happy to look through possible causes, however at the moment i need to treat the symptom and see if i can locate these eroneous instances and close them.
Then i can look into possible causes further, i am not beoynd thinking my code may be causing it. However I do think that it may be a problem inside office itself....
HiTechCoach
05-16-2012, 09:04 AM
Yes,
The instances that are created when done are set to visible to the user and then all programing interfaces are closed and or set to nothing as needed. The user edits the document, saves then closes word. HOWEVER sometimes (not every time) some times the word process will remain open after the user tells word to close. As i mentioned the MSACCess.exe process sometimes remains running after they close our database too. I don't believe there is a programing issue that is causing this as i have seen similar problems on machines not running our system.... I would be happy to look through possible causes, however at the moment i need to treat the symptom and see if i can locate these eroneous instances and close them.
Then i can look into possible causes further, i am not beoynd thinking my code may be causing it. However I do think that it may be a problem inside office itself....
I find that majority of the time this is cause by the code. What I commonly see is that coding issues do not cause any errors. But it does cause multiple instances to be created without you knowing. It is similar to variables when you do not not use Option Explicit. Unfortunately Option Explicit does not help with this issue.
Note: When Word does a mail merge with an .mdb/.accdb it always creates anothwer instance of Access. Even when using automation. This is a common cause of an MSACCESS.EXE left running but not visible when using automation. I find it best to avoid using an Access database as the merge source.
Movian
05-16-2012, 11:07 AM
understood,
The system is using a SQL database as the back end. Also we are not doing a traditional Mail Merge. The system opens the document then systematicaly goes through each bookmark in the document and replaces the text with the value required then makes it visible to the user and closes out the instances. We did this as mail merge has some funky behavior and we wanted our documents to be completly seperated from the database when created.
I will look through again but all of the instances are set to close out.
So in the short term im still left with the need to cure the symptom and close the processes in code till i can fix what is leaving them open. Any suggestions on that ?
essentialy to use an example, i know that i need to take my patient to the hospitol but we don't know where the hospitol is or how far away it is so i need to apply imediate first aid to stem the bleeding until i can get them there....
Tommy
05-16-2012, 02:40 PM
Movian,
I don't know how much help this will be but when I kept leaving instances of word going it was because I had a varable set to the bookmarks and forgot to set it to nothing before I closed word (I know you are not closing word), I also forgot to set a varable I was using for tables (this one started me to drinking). :) I was reusing it several times and on the last one didn't set it to nothing. Then I forgot to kill the doc vairable.
To get rid of these instances do a getobject to grab it and close it, do this until all are gone of course.
The Bandaid below will kill all instances of Word, it will not save any changes this is pure brute force as you can tell.
usage:
While BandAid
Wend
Function BandAid() As Boolean
Dim Wrd As Word.Application
On Error Resume Next
Set Wrd = GetObject(, "Word.application")
If Err.Number = 0 Then
Wrd.Quit SaveChanges:=False
KillWrd = True
End If
Set Wrd = Nothing
Err.Clear
On Error GoTo 0
End Function
EDIT: I didn't show how to use it/ and I still can't spell.
Movian
05-17-2012, 01:29 PM
Ok Thanks for the solution im currently testing this out. along those same lines im guessing i could do the same thing with Access, is there a way to exempt the process its run from ?
So i want to close all OTHER instances of Msaccess.exe except the one doing the closing. Once thats done i can put the bandaid in place and work on the real fix of finding out why they are staying open in the first place.
Tommy
05-18-2012, 07:58 AM
My initail though was to close all instances on the variable initializations. This way you can open word without worring about if it is an existing or new instance.
I do not have access to work with so I can not say that the same thing will work for sure but I would think it does.
I would check the processid I think it is, before closing the instance and compare it to the one you are (you are the current instance).
Are you closing and reopening word or access? if you are you may need to make sure you are saving the docs or telling word you do not want to. That one bit me a couple of times.
I don't know how much trouble this would be but try to write a sub that write the values of all of you public vars. Write the staus of each to an ASCII file, this will help in the future when there are problems. Setup a catch all error funtion and dump this information.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.