Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Problems with VFP dll in Excel
I have written a DLL using VFP 6.0 SP4. The DLL operates fine in VFP, but I'd like to also use it in, for example, Excel 97.
The code I use in VFP to use the DLL is:
oTest = CreateObject("refgen.ref_finder")
cName = oTest.getref("substanc", "numb", "AZZZD", 1)
Release oTest
MessageBox(cName)
The above code runs with no problems, and can be run multiple times without problems.
The code for my macro in Excel is as follows:
Dim oTest As Object
Set oTest = CreateObject("refgen.ref_finder")
cName$ = oTest.getref("substanc", "numb", "AZZZD", 1)
Set oTest = Nothing
MsgBox (cName)
This works fine when I run it once. However, if I run the same macro a second time I get the following error.
Run-time error '-2147467259 (80004005)':
Automation error
Unspecified error
The error occurs at the CreateObject line. To get the dll to work again, I have to shutdown and restart Excel.
Does anyone have any idea what this means ? I thought that maybe the object wasn't being destroyed properly, but it seems OK in VFP, and the debugger in Excel shows the value of oTest as being "Nothing".
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement