Word object fails on production

Hi AllI have an agent on production. The agent usually performs below operation

  1. Reads a text file from NT folder

  2. Copies the text in to a Word document template(coded with macro)

(word macro just converts the copied text to a tiff file.)

  1. Agent code run the macro in the word and places the tiff file in another NT folder.

The above agent runs fine on UAT but on production the agents creates word object and then stops. the word object does not get deleted and after some time server hangs unitll word object is manually deleted.

UAT and prod environments are in sync. this agent use to run fine on prod… since few days it is behaving strangely.

Can any one provide the solution.

Hi Wayne thanks of your advise

Here is the sub thats stopping agent to process further, the problem line ie preceeded by (***)

On Error Goto ErrorHasOccurred

Dim createcopy As String

Dim actualname

Dim extension As String	

filepath=autoconfigdoc.Fieldname1(0)

backupfilepath=autoconfigdoc.backFieldname2(0)		

(***) createcopy=Dir$(filepath,0)

Do While createcopy<>""		

	actualname=Strleft(createcopy,"_")+"_"+Strleft(Strright(createcopy,"_"),"_")

	extension=Lcase(Strright(createcopy,"."))

	Msgbox "===========>>>>>>>>>>>>>>>changefilename" & backupfilepath & actualname & "." & extension

	Filecopy filepath+createcopy, backupfilepath+actualname+"."+extension		

	Kill filepath+createcopy

	createcopy=Dir$(filepath,0)

Loop

Exit Sub	

ErrorHasOccurred:

LogMessages= Cstr(Now()) & " ~ Error in agTCS_Mot_AS24    ~ Sub changefilename " & Erl() & " Error " & Error()

Call CreateLogEntry(Logmessages, "TCS/MOT/AS24","ERROR Log")

Exit Sub

Thanks in advance

Subject: You need to post your code…

I was going to make a sarcastic comment, but given that this appears to be your first posting I will refrain myself. Reduce your code to the minimum amount that can still produce the problem in prod only and post it here and someone might be able to offer some suggestions. Given that you say the code works in one environment but not the other it might not be that easy to deduce.