Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

vba not releasing files in dll

billaustralia
Beginner
663 Views
From Excel vba, I call a vf dll which opens and reads part of a file, then returns to the vba. Normally, another call to the vf dll occurs and more is read from the file.

But in some circumstances, I want to quit and return to the initial situation. So I execute
END
in the vba which finishes the vba and unloads the dll.
But the file is now inaccessible.

Any way around this? other than closing the file before each return...
0 Kudos
2 Replies
rahzan
New Contributor I
663 Views
I canonly guess as to what you mean by "file is now inaccessible". But I have an idea what it means.

It sounds like you are NOT using a com server. If you did upon unloading the DLL the destructor for the com-server is called whereupon you can close the file.

If you do not want to do that, implemnent the clean up manually in your DLL and call it just before you call the END in VBA.

Tim
0 Kudos
TimP
Honored Contributor III
663 Views
You certainly need to close the file before it can be re-opened. From your last comment, I take it that you're not even attempting to close it. Evidently, vba has no way of automatically closing files opened by Fortran.

On XP, with certain applications installed, such as United Devices, the OS may ignore one or more of the API calls involved in closing a file, so the "in-use" lock remains set until reboot. Similar things will happen on any Windows if a file is shared,opened from elsewhere on the network, and the network connection dies.
0 Kudos
Reply