+ Reply to Thread
Results 1 to 2 of 2

Import a macro (module) into the active Excel workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Import a macro (module) into the active Excel workbook

    Hello everyone and thank you for reading my post. I am having trouble importing a module (VBA macro). I have two excel workbooks open one is host, the other is export. The export workbook is a copy of a worksheet originating from the host workbook. The first part of my code works fine:

    Workbooks(Host).Activate
    ActiveWorkbook.VBProject.VBComponents("ResetXFER1").Export ("C:\ResetXFER1.bas")
    then I make the export workbook active and try to import the module like this:

    Workbooks(NWBN).Activate: Sheets("Upload_Template").Select
    Application.VBE.ActiveVBProject.VBComponents.Import ("C:\ResetXFER1.bas")
    and it imports into the Host instead of NWBN. I suppose activating a workbook is not the same as activating the VBProject, but that's just a guess. In short, the import works but imports into the wrong workbook. Can anyone suggest how to import into NWBN.

    Many thanks to all,
    Roger

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Import a macro (module) into the active Excel workbook

    Hi

    I got it to import into the required workbook using the form

    ActiveWorkbook.VBProject.VBComponents.Import ("C:\ResetXFER1.bas")
    but I'm not sure that it will be going into the specific module that you want.

    rylo

+ 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