Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    Using VBA to make a dll library (VBA (XP))

    Now I have my Tree working in Word, I need to do the same for Excel etc - yes, I could just copy the code but I'd like to have just one copy of the code. So I created an Add-In project, copied over the bits and made a .dll. Then I created a new test doc and wtote:

    Option Explicit
    Private Declare Sub GetSelectedPath Lib "ArrowLALib" _
    (ByVal nDir As String, ByVal aDir As String)
    Sub TestIt()
    Dim strAns As String

    strAns = String(255, vbNullChar) ' null it
    GetSelectedPath "Cata", strAns
    MsgBox strAns
    End Sub

    But it cannot find Dll entry point GetSelectedPath - what do I have to do to make it visible? (It is already public)

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Using VBA to make a dll library (VBA (XP))

    Uhhhhh... you created an MS Office COM Add-in DLL? If so, I think there are easier ways to call its code than using Declare, which seems tailored to stuff created in the C languages. In fact, as long as the Add-in is loaded, I think you just call the function as though it were part and parcel of your project. But I'm not sure I really understand what's going on here.

  3. #3
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    Re: Using VBA to make a dll library (VBA (XP))

    I've tried removing the declare and referencing the dll manually but it gets the same compile error. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to make a dll library (VBA (XP))

    Create an ActiveX DLL.
    Register the DLL on the system.
    Add a project reference to the DLL.
    Instantatiate the class in the code that references the class.
    Refer to the class via the unstantiated class.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Using VBA to make a dll library (VBA (XP))

    I'm sorry, I need you to be more specific for me. You created the DLL. Where is the DLL in the target user environment? The scenario I was trying to describe is this: a COM Add-in you added to your Word/Excel environment using the COM Add-ins dialog.

Posting Permissions

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