As a bit of a background i have used a word document to add several command buttons. The document is used as a bit of a menu to open various other documents. When one of these buttons is pressed the code checks a .ini file for various things before it opens the desired document.
One of the problems i was having with the .ini file is that i wasn't opening/closing the object properly and as a result it didn't take long for a huge amount of WINWORD.EXE proccesses to appear and cause me grief. To try and prevent this i tried to change the code i had written to open up the .ini file to declare and delete the word.exe objects (if thats what they are called). This worked and i no longer get the WINWORD.EXE processes still appearing when i had finsihed when them.
This worked for a while but i'm now getting an error message every time i press one of the buttons.
"This file is in use by another application or user. (C:\Documents and Settings\...\Normal.dot)"
Now im no expert in VBA but i thought the problem might be that i am creating a word object to look at the .ini file (even though one has already been created automatically to open the Word menu) and i am then trying to delete that object even though it might still be in use by the Word menu. This menu system is used by about 10 other people who don't get this error message. I have also tried deleting the normal.dot template incase that was the isue.
The code i use to open the .ini file is
Function ReadINI(Path As String, Section As String, _
Key As String) As String
Dim wd As Word.Application
fileName = Path & "\settings.ini"
ReadINI = ""
Set wd = New Word.Application ' create the Word application object
On Error Resume Next
ReadINI = wd.System.PrivateProfileString(fileName, Section, Key)
On Error GoTo 0
Set wd = Nothing ' destroy the Word application object
Is there a problem with the way i am reading the .ini file or does it lay with Word and the template?
If it is the code, i still need some way to delete the word object every time i read the .ini file to stop it creating a large amount of redundant processes.