>I have a function that put data in an excel file. The first time the program access this function, It use the CreateObject method and the other times, It use the GetObject one. But this is not working. Do you have an idea why? Here is the code of the function:
>
>Set application = CreateObject("Excel.Application")
>
>if ecriture = 1 Then
> Set fichier = CreateObject("Excel.Sheet")
>else
> Set fichier = GetObjec("M:\DACE\PROJET_DMS\Test\test.xls","Excel.Sheet")
>end if
>
>
>fichier.ActiveSheet.Cells(ecriture,1).Value = valeur
>fichier.ActiveSheet.Cells(ecriture,2).Value = annee
>
>fichier.SaveAs "M:\DACE\PROJET_DMS\Test\test.xls"
>
>
>fichier.Application.Quit
>Set fichier = Nothing
Hi there,
Where in this function are you setting the value of "ecriture" so it knows which section of the IF-THEN-ELSE to fall in to?
Also, since you are releasing the "fichier" object on each pass through the function with the "Set fichier = Nothing", just use the CreateObject() function, as the previous Excel.Sheet object is no longer in memory. GetObject serves no purpose here.