+ Reply to Thread
Results 1 to 11 of 11

How do I copy a macro module to another workbook?

  1. #1
    Forum Contributor
    Join Date
    12-26-2005
    Location
    annapolis, Md.
    MS-Off Ver
    2007
    Posts
    260

    How do I copy a macro module to another workbook?

    I have 4 macros in the "personal" workbook. I am trying to copy one of them to another workbook. I found instructions at the following link and have been able to do everything it says except the last step which says "Drag the module that you want to copy to the destination workbook".
    Please tell me how to do that [ie] I can click on and drag it but don't know where to drag it to?

    http://office.microsoft.com/en-gb/ex...010014116.aspx

    Copy a macro module to another workbook
    Applies to: Microsoft Office Excel 2007
    If the Developer tab is not available, do the following to display it:
    1. Click the Microsoft Office Button , and then click Excel Options.
    2. In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
    NOTE The Ribbon is a component of the Microsoft Office Fluent user interface.
    2. To set the security level temporarily to enable all macros, do the following:
    1. On the Developer tab, in the Code group, click Macro Security.

    2. In the Macros Settings category, under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
    NOTE To help prevent potentially dangerous code from running, we recommend that you return to any of the settings that disable all macros after you finish working with macros.
    1. Open the workbook that contains the module that you want to copy and the workbook that you want to copy the module to.
    2. On the Developer tab, in the Code group, click Visual Basic.
    3. On the View menu, click Project Explorer .
    4. Drag the module that you want to copy to the destination workbook.
    Last edited by Joe Miller; 06-16-2010 at 01:28 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I copy a macro module to another workbook?

    Alt+F11 to open the VBE

    Ctrl+R to open the Project Explorer window if it's not already open.

    Expand the project in Personal.xls to show the modules

    Drag the modules of interest onto the project for the target workbook.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    12-26-2005
    Location
    annapolis, Md.
    MS-Off Ver
    2007
    Posts
    260

    Re: How do I copy a macro module to another workbook?

    I see VBAProject(EURUSD1440.csv)
    VBAProject(FUNCRES.XLAM)
    etc.
    I have absolutely astounded that I have gotten this far. I don't know what to drag it to. I have unsuccessfully tried various things.

    I understand this may be too much to handle in a forum.

    All the cntl's and alt's are really cool shortcuts.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I copy a macro module to another workbook?

    It will be shown as VBAProject(Your workbook name)

  5. #5
    Forum Contributor
    Join Date
    12-26-2005
    Location
    annapolis, Md.
    MS-Off Ver
    2007
    Posts
    260

    Re: How do I copy a macro module to another workbook?

    I get no response when I do a Cntl+R?
    When I do an Alt+F11 what I think is the Project Explorer window is displayed. Please see attachment. I think I successfully attached a Word file showing the Project Explorer window If not attached please tell me how to attach a file. I have searched the forum for directions but have not found any. I know they must be out there somewhere.

    I have tried several things working with the Project Explorer window with no success.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I copy a macro module to another workbook?

    No attachment.

    All the relevant instructions are in the forum rules. If your attachment needs to be smaller, zip it. If it's sill too large, reduce it to the relevant information.

  7. #7
    Forum Contributor
    Join Date
    12-26-2005
    Location
    annapolis, Md.
    MS-Off Ver
    2007
    Posts
    260

    Re: How do I copy a macro module to another workbook?

    I have been trying to copy macros from the personal workbook to one of the workbooks whose name is in the personal workbook with the idea that I could then delete the personal workbook from XLSTART located in
    C:\Documents and Settings\your name\Application Data\Microsoft\Excel\XLSTART – the objective being to preclude the personal workbook from appearing everytime I start up other Excel programs that don’t use macros. In other words I have been thinking that the specific macro for the specific workbook would then be embedded with that workbook and always be available to use in that workbook with no need for a personal workbook. Asked another way, do macros need a personal workbook even if the macro code is “embedded” in the Excel program – if not, then I can copy the macro from the personal workbook and then delete the personal workbook so that the personal workbook is no longer a bother when I don’t need it?

    Is the above concept of the design of Excel and macros true? If so I can continue to pursue the issue. Otherwise what I have been trying to do has been wasted time, except that I have learned a few things.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I copy a macro module to another workbook?

    A macro can be stored in personal.xls, an add-in, or a workbook. Wherever it's stored, if can operate on any open workbook as long as the workbook it's in is open/installed (installed being the terminology for add-ins).

    So it sounds to me like what you want is an add-in that you can load and unload as desired: http://www.fontstuff.com/vba/vbatut03.htm

  9. #9
    Forum Contributor
    Join Date
    12-26-2005
    Location
    annapolis, Md.
    MS-Off Ver
    2007
    Posts
    260

    Re: How do I copy a macro module to another workbook?

    I will be using a macro only in a workbook which I have opened. It will be used in no other workbook. In which case it sounds like the best place to store it is in the workbook.Then I will not be bothered with "personal" files appearing which will be of no use to me.

    I will recreate my macros - each macro tallored for the particular Excel program it is in. That will probably be the best way to clean up this mess I created. Please let me know if you disagree.

    Thanks for your invaluable help. Much appreciated.

    I will remember to mark this thread closed.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I copy a macro module to another workbook?

    Then I will not be bothered with "personal" files appearing which will be of no use to me.
    Opinions vary on that -- I have lots of stuff in Personal.xls that I like to have at hand rather than searching my library for it. Andy Pope doesn't use one at all.

    I will recreate my macros - each macro tallored for the particular Excel program it is in. That will probably be the best way to clean up this mess I created.
    Cleaning stuff up is always a good thing. I would be careful to factor out all those things that can conveniently be reduced to short subs and functions and reused for all.

  11. #11
    Forum Contributor
    Join Date
    12-26-2005
    Location
    annapolis, Md.
    MS-Off Ver
    2007
    Posts
    260

    Re: How do I copy a macro module to another workbook?

    Your points make sense, especially for a guru. Primary for me is to try to keep it where I am most comfortable with my limited experience [which at times results in a huge complicated mess].
    Anyhow, thanks again - you have been great.

+ 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