Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VBA - Declare - Finding the Lib File - Windows Registry?

VBA - Declare - Finding the Lib File - Windows Registry?

Scheduled Pinned Locked Moved Visual Basic
javascriptwindows-adminquestiondiscussion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JSadleir
    wrote on last edited by
    #1

    Hi All I have a Microsoft Excel Add-in written in VBA. It includes a function that calls a .dll via a Declare statement along the lines of: Declare Function SOMEFUNCTION Lib "c:\Program Files\SomeFunction.dll" (ByVal SomeNo as Double) as Double Instead of including the full path to the Lib file such as "c:\Program Files\SomeFunction.dll", it is possible to register the SomeFunction.dll in the Windows Registry so that I can avoid the fiddly process of finding the path to the file so the Declare Statement becomes: Declare Function SOMEFUNCTION Lib "SomeFunction.dll" (ByVal SomeNo as Double) as Double Is that right? How do you register a .dll with Windows Registry? Is the REGEDIT.ex the only way? Is there some other way? Any suggestions or thoughts on this would be much appreciated. Thanks JS

    D 1 Reply Last reply
    0
    • J JSadleir

      Hi All I have a Microsoft Excel Add-in written in VBA. It includes a function that calls a .dll via a Declare statement along the lines of: Declare Function SOMEFUNCTION Lib "c:\Program Files\SomeFunction.dll" (ByVal SomeNo as Double) as Double Instead of including the full path to the Lib file such as "c:\Program Files\SomeFunction.dll", it is possible to register the SomeFunction.dll in the Windows Registry so that I can avoid the fiddly process of finding the path to the file so the Declare Statement becomes: Declare Function SOMEFUNCTION Lib "SomeFunction.dll" (ByVal SomeNo as Double) as Double Is that right? How do you register a .dll with Windows Registry? Is the REGEDIT.ex the only way? Is there some other way? Any suggestions or thoughts on this would be much appreciated. Thanks JS

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Well, VBA is a little limited in this respect. You can't register library .DLL's like you can COM .DLL's. Also, you can't change the location of your reference at runtime in VBA, so putting the path to the .DLL in the Registry isn't going to help much. If you don't want to put the full path to the .DLL in your declaration, you're limited to putting the .DLL where it can be found without it. The best place to put the .DLL is in the directory your code is launched from, usually in Program Files\myAppFolder. You could also put it in C:\WINDOWS, or more acurately, %SystemRoot%. If your .DLL is not in the current directory, the loader then tries to find your .DLL in the each folder listed in the PATH environment variable. If it's not found in the PATH, your function call will fail miserably. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Well, VBA is a little limited in this respect. You can't register library .DLL's like you can COM .DLL's. Also, you can't change the location of your reference at runtime in VBA, so putting the path to the .DLL in the Registry isn't going to help much. If you don't want to put the full path to the .DLL in your declaration, you're limited to putting the .DLL where it can be found without it. The best place to put the .DLL is in the directory your code is launched from, usually in Program Files\myAppFolder. You could also put it in C:\WINDOWS, or more acurately, %SystemRoot%. If your .DLL is not in the current directory, the loader then tries to find your .DLL in the each folder listed in the PATH environment variable. If it's not found in the PATH, your function call will fail miserably. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        J Offline
        J Offline
        JSadleir
        wrote on last edited by
        #3

        Many thanks Dave - That sheds much light - It's a shame that the Program Folder can't be reached as effortlessly as the Windows folder - Thanks again - JGS

        D 1 Reply Last reply
        0
        • J JSadleir

          Many thanks Dave - That sheds much light - It's a shame that the Program Folder can't be reached as effortlessly as the Windows folder - Thanks again - JGS

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Wanna bet? %ProgramFiles% Try typing SET at a CMD prompt. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups