+ Reply to Thread
Results 1 to 5 of 5

Catch non-existent dll compile errors

  1. #1
    Registered User
    Join Date
    01-07-2009
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Catch non-existent dll compile errors

    I have created a dll in .NET that i use it in excel. End users who use the excel workbook need to register the dll when they first use the workbook. Sometimes, they fail to register the dll and launch the workbook. The workbook has a reference in it to the .dll. As soon as they try to do anything they get a compile error "User-defined type not defined". This is because:
    Please Login or Register  to view this content.
    and the "unit.dll" has not been registered to work with excel.

    What i want to do is to catch and interrupt the compile error gracefully and tell the user to go back and re-register the dll before using the workbook. As it stands now they just see compile error - and well you can imagine when they are looking at the vb screen quite confused.

    So i thought maybe i would create a type
    Please Login or Register  to view this content.
    but you can't have a type without members. And i'm not sure how this would work once someone registers the user-defined type by the same name.

    So - any ideas how to solve this problem?

    Thanks,

    -lta
    Last edited by likestheaction; 01-09-2009 at 05:08 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Can't you just put On Error Resume Next before the New, and test for an error afterward?

    Edit: Never mind that, it's a compile error, sorry.

    Switch to late binding, and then test for an error:
    Please Login or Register  to view this content.
    Edit2: Please take a few minutes to read the Forum Rules, and then edit your post to wrap your code with Code Tags.
    Last edited by shg; 01-07-2009 at 08:51 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-07-2009
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2003
    Posts
    2
    Thanks. I will try the late binding approach. I also tried below, and it works as well. I found it on some other website. Where UNITS_LIBRARY_NAME is a constant for the name of the dll. In the following example no references or object creation is necessary. So a different approach to the solution than my question indicated.

    -lta

    Please Login or Register  to view this content.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Don't you still get a compile error if you use early binding in the main code?

    You can also test for an add-in using GUID, I think, though I've not used it.

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

    Here is a routine that will check if the DLL files exists or not. If it does exist, VBA will attempt to register it. If it doesn't exist, the user is alerted. You can change the file name and path to what you are using.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

+ 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