+ Reply to Thread
Results 1 to 5 of 5

implicit file reference

  1. #1
    Registered User
    Join Date
    02-08-2006
    Posts
    3

    implicit file reference

    Hello,

    I'm declaring a DLL file (one of my own creation) in VBA with an explicit directory reference thus:

    Private Declare Function GetQuote Lib _
    "C:\Documents and Settings\Pooka\Desktop\d3\StockMarket.dll" () As Long

    Since this isn't a standard .dll, it is in the same directory as the .xls file that is calling it. My desire is to be able to send the .xls and .dll files together to a friend and have them work together in any directory without having to modify the VBA decleration. I tried the following in hopes it would just look in the same directory as the .xls file:

    Private Declare Function GetQuote Lib _
    "StockMarket.dll" () As Long

    But it said it couldn't find the .dll file. Is there any way I can get around this so that it won't break the moment I move the files into another directory? (I have tried using CurDir, but the "working" directory which this function returns is not the same as the directory containing my .xls file.)

    Regards,

    Matt

  2. #2
    Tim Williams
    Guest

    Re: implicit file reference

    Matt,

    Maybe this might help...

    http://groups.google.com/group/micro...c4aca9a609de4a

    --
    Tim Williams
    Palo Alto, CA


    "Tuee" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hello,
    >
    > I'm declaring a DLL file (one of my own creation) in VBA with an
    > explicit directory reference thus:
    >
    > Private Declare Function GetQuote Lib _
    > "C:\Documents and Settings\Pooka\Desktop\d3\StockMarket.dll" () As
    > Long
    >
    > Since this isn't a standard .dll, it is in the same directory as the
    > xls file that is calling it. My desire is to be able to send the .xls
    > and .dll files together to a friend and have them work together in any
    > directory without having to modify the VBA decleration. I tried the
    > following in hopes it would just look in the same directory as the .xls
    > file:
    >
    > Private Declare Function GetQuote Lib _
    > "StockMarket.dll" () As Long
    >
    > But it said it couldn't find the .dll file. Is there any way I can get
    > around this so that it won't break the moment I move the files into
    > another directory? (I have tried using CurDir, but the "working"
    > directory which this function returns is not the same as the directory
    > containing my .xls file.)
    >
    > Regards,
    >
    > Matt
    >
    >
    > --
    > Tuee
    > ------------------------------------------------------------------------
    > Tuee's Profile:

    http://www.excelforum.com/member.php...o&userid=31344
    > View this thread: http://www.excelforum.com/showthread...hreadid=510327
    >




  3. #3
    Registered User
    Join Date
    02-08-2006
    Posts
    3
    Thanks for the reply. I'm new to this, so please pardon my density... does this explain how to make an indirect file reference (if that's even the right term)? I don't quite see the connection...

  4. #4
    Tim Williams
    Guest

    Re: implicit file reference

    Well, OK I didn't actually test that but i was assuming that you could
    (dynamically) add a reference to your dll using the code outlined in the
    post, then just call your functions without needing a "Declare...."
    statement.

    You would build the path to add the reference using "thisworkbook.path" and
    the filename for your dll.

    Tim


    "Tuee" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Thanks for the reply. I'm new to this, so please pardon my density...
    > does this explain how to make an indirect file reference (if that's
    > even the right term)? I don't quite see the connection...
    >
    >
    > --
    > Tuee
    > ------------------------------------------------------------------------
    > Tuee's Profile:
    > http://www.excelforum.com/member.php...o&userid=31344
    > View this thread: http://www.excelforum.com/showthread...hreadid=510327
    >




  5. #5
    Registered User
    Join Date
    02-08-2006
    Posts
    3
    Okay, I've tried:

    Private Declare Function MeaningOfLife Lib _
    thisworkbook.path & "StockMarket.dll" () As Long

    But it says Error: expected string constant on "ThisWorBook.Path". Is this a string? What would be the correct usage here?

+ 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