Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with VFP dll in Excel
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00463519
Message ID:
00463569
Views:
36
Matt,
I don't know for sure, but could it be that the SECOND time you already have the oTest object? You might try deleting it in your macro or else checking to see if it exists before calling CreateObject()

I've run into similar problems with Word....

HTH
Barbara

>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".
Barbara Paltiel, Paltiel Inc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform