+ Reply to Thread
Results 1 to 3 of 3

A dll call in vba makes excel bug ???

Hybrid View

alpha35 A dll call in vba makes excel... 09-01-2007, 02:13 PM
Leith Ross Hello Alpha35, You say... 09-01-2007, 11:10 PM
alpha35 Leith, I have a problem on... 09-02-2007, 12:59 AM
  1. #1
    Registered User
    Join Date
    09-01-2007
    Posts
    2

    A dll call in vba makes excel bug ???

    Hello,

    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 close...:

    Error signature:
    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.

    At first 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 c:\windows\system32\user32.dll").

    Private Declare Function GetSystemMetrics Lib "c:\u32.dll" (ByVal nIndex As Long) As Long
    Sub AfficherResolution()
    Largeur = GetSystemMetrics(0)
    Hauteur = GetSystemMetrics(1)
    MsgBox "La résolution de votre écran est de " & Largeur & " par " & Hauteur
    Exit Sub
    End Sub
    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:\windows\system32 and remove 'c:\' in front of u32.dll in the vba code, the problem is still here.
    - 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.

    My config : excel 2003 sp2, windows XP Pro SP2.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Alpha35,

    You say that U32.dll is the same as User32.dll. Having a copy of a System executable file is going to create some problems. Renaming the User32.dll to U32.dll wouldn't be a good move either. So, why are you doing this? Curiosity?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    09-01-2007
    Posts
    2
    Leith,

    I have a problem on a dll which is not a system dll. To detect if this is specific to my dll or to excel/vba, I tried to use a system dll after having renamed it.

    The result is that the problem is occuring with the system dll. So I should not be the only one facing this ! Either it is an excel bug or there is something I forgot in the vba Declare command...

    Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1