+ Reply to Thread
Results 1 to 4 of 4

Inserting module to ActiveWorkbook

  1. #1
    Registered User
    Join Date
    02-25-2010
    Location
    Osielsko
    MS-Off Ver
    Excel 2003
    Posts
    21

    Inserting module to ActiveWorkbook

    Hello,

    How can I insert code in ThisWorkbook module in Workbook_Open event? I would like something like code in code so I can write in my macro line by line what should be putted in Workbook_Open in ActiveWorkbook.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Inserting module to ActiveWorkbook

    Good evening owiec

    Try using this code :

    Please Login or Register  to view this content.
    Before you run it set a reference within the VBE to Microsoft Forms 2.0.
    Go to Tools > References, find and tck "Microsoft Forms 2.0 Object Library" and click OK.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    02-25-2010
    Location
    Osielsko
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Inserting module to ActiveWorkbook

    Hi,

    Thanks for reply.

    I get error Subscript out of range and it points to
    Set wbcodemod = ActiveWorkbook.VBProject.VBComponents(ActiveWorkbook.CodeName).CodeModule
    When I put something like MsgBox ActiveWorkbook.CodeName its returne blank window. Should it be like that?

    I know that ActiveWorkbook is working cuz when I put MsgBox ActiveWorkbook.Name it returns aproperiate value.
    Last edited by owiec; 03-12-2010 at 03:53 AM.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Inserting module to ActiveWorkbook

    Hi owiec

    Your profile states you are running XL2003. Is this still the case?

    I tested the code last night on an XL2003 and it worked fine. I've tested it again this morning on a different machine and it still works fine.

    Try running the macro in the attached file and let me know how it goes.

    HTH

    DominicB
    Attached Files Attached Files

+ 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