I am facing a very difficult problem with Excel 2003 under windows XP:
My vba sub calls a dll
subroutine. Thus I use declaration: Private Declare Function myFunction Lib "c:u32.dll" in the vba module.
When I am calling my vba sub in excel sheet, everyting works fine.
The problem is when I close the spreadsheet, I get the message Microsoft Excel encountered a problem and needs to
AppName: excel.exe AppVer: 11.0.6560.0 AppStamp:4296b6f2
ModName: ntdll.dll ModVer: 5.1.2600.2180 ModStamp:41109627
fDebug: 0 Offset: 0000eae0
Sometimes, this error comes also randomly before closing the sheet.
I believed that there was a problem in the dll but it is not the case: if I call GetSystemMetrics in user32.dll the same
problem occurs: here is the vba code raising the message at sheet closure (c:u32.dll is the same file as
Private Declare Function GetSystemMetrics Lib
"c:u32.dll" (ByVal nIndex As Long) As Long
Largeur = GetSystemMetrics(0)
Hauteur = GetSystemMetrics(1)
MsgBox "La résolution de votre écran est de " & Largeur & " par " & Hauteur
Some additionnal remarks:
- when I replace c:user32.dll by user32.dll only, the problem disappears.
- when I put the u32.dll file in c:windowssystem32 and remove 'c:' in front of u32.dll in the vba code, the problem is still
- after call of the vba sub (which calls c:u32.dll) and before closure of the sheet, the file c:u32.dll cannot be deleted
(acces denied) it is sill open.
Can anybody help me ?
Thanks a lot for your help.
: excel 2003 sp2, windows XP Pro SP2.