Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

"include" a module in VBA

Options
  • 27-03-2009 12:32pm
    #1
    Registered Users Posts: 901 ✭✭✭


    Hello,

    I'm looking for the equivilent of an "include" statement in VBA. I want to hold functions centrally and be able to call this .bas file for all my other projects.

    I found a solution whereby you run a macro to import your file holding the code, but that would have to be called every time you open an excel sheet you want to use it in. It just seems a bit clunky.

    Is there a nice and simple "include c:\vba\mycode.bas" type statement?


Comments

  • Registered Users Posts: 6,465 ✭✭✭MOH


    There's possibly an answer here, but I can't be bothered going through the whole stupid expert-sex-change signup routine.


  • Closed Accounts Posts: 18,056 ✭✭✭✭BostonB


    Is there a reason you don't want one macro with all the code in one place that does everything rather than a bunch of macros that do very similar things, and keep the code somewhere else.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Or just build it into a dll and include that


  • Closed Accounts Posts: 18,056 ✭✭✭✭BostonB


    We did this before with dll's and exe's, but in hindsight I don't see the point. Its just makes deployment and updates a pain. I switched to one main template that contained all the code in a network location, that could be updated on the fly.

    The only time I really see the need is if you want to build a form with functionality that VBA can't do, or where you want to hide the code from other developers because its a commercial products.

    But maybe you've another valid reason for it.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Look BostonB said, you can end up with DLL hell...

    Otherwise, just use Web Services

    EG http://www.dotnetspider.com/resources/58-STEP-BY-STEP-Consuming-Webservices-rough-VBA-E.aspx


  • Advertisement
Advertisement