+ Reply to Thread
Results 1 to 10 of 10

How to call a procedure from a different module, witihin "ThisWorkbook"

  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Question How to call a procedure from a different module, witihin "ThisWorkbook"

    OK - I thought I understood this as I am doing it in other locations within my code.

    While being in one module named "ModReportGenerator", I call to run other various procedures from other modules by using the naming convention of "modulename.procedurename" and this seems to work just fine.

    But if I try to do this same thing within the"ThisWorkbook" sheet, this naming convention doesnt work and I am not able to call up a procedure.

    My goal is to run the procedure named CLEAR that is located on module "ModInvoiceTabel" and run this code on "ThisWorkbook"

    I tried:
    Please Login or Register  to view this content.
    and this doesnt work.
    Last edited by clemsoncooz; 02-08-2012 at 10:01 AM.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    If the routine is declared public, it should work the same when called from ThisWorkbook as it does from anywhere. The phrase "doesn't work" is not particularly helpful though.
    Good luck.

  3. #3
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    So what error do you get?

  4. #4
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    Not that it matters but in my first post, I spelled table wrong. I really tried the correct spelling in excel, and I still get an error.

    I get:
    Compile Error:
    Method or data member not found.

    And the routine is Private. (i.e -
    Please Login or Register  to view this content.

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    You said you were trying to run a sub in a normal module, so it is whether that called sub is public or private that matters, not whether the calling sub is.

  6. #6
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    Oh, THAT SUB (CLEAR) is Private. It has to be public for it to work correctly?

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    Yes. The whole point of making it Private is so that it cannot be called from other modules.

  8. #8
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    Oh, ok. Thanks. I didnt know that.

    I just thought making it Private was so that it will not show up in the MACROS dialog box, that lists all the Public Macros.

    Is there a way to have my sub within ThisWorkBook, to call a sub located in another module (that it sounds like has to be Public) - but not let it show in the Macros dialog box that lists all the public macros?

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    You can leave the routine private and use
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: How to call a procedure from a different module, witihin "ThisWorkbook"

    Perfect. Thank you!!

+ 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