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:
00464033
Views:
30
Matt,

Check your Task Manager to see if the DLL is left open as a process when you run your macro.

I did some experiments with Excel using Word as my "createobject". I found that I had to actively quit Word with "oTest.quit" before WinWord disappeared from my Task Manager. Otherwise every time I ran the macro I got another copy of WinWord running. Not visible on the Application tab (hadn't used oTest.show) but visible in processes.
Static oTest As Object

Set oTest = CreateObject("word.application")

oTest.Quit
Set oTest = Nothing
Maybe you could try a VFP Release command? Sorry I didn't have a VFP DLL to try out, but I could repeat the 'nonrelease' of the "Set oTest = Nothing" command.

I also found that I had to issue the "Quit" command before setting the object to "Nothing" (got an error otherwise) which confirmed your finding that the value WAS changed.

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