+ Reply to Thread
Results 1 to 10 of 10

how to run macro from active workbook, without opening source workbook??

  1. #1
    Registered User
    Join Date
    09-09-2010
    Location
    Haugesund, Norway
    MS-Off Ver
    Excel 2003
    Posts
    33

    how to run macro from active workbook, without opening source workbook??

    Hi,

    I have created macro, assigned it to button on quick access toolbar. When i save workbook with different name and then when I pushing this button on quick access toolbar, original workbook opens and macro is starting up from it, not from current workbook with different name. But when I use hot-keys to run this macro, it is starting from active workbook (as I want).

    What I'm thinking is, that when I assign macro to the button, it only assigns to only that certain macro. But how to assign that like "public" not "private" ?

    Sorry for my pure english, but hope you understand what I mean

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: how to run macro from active workbook, without opening source workbook??

    Is this a macro that you want to have available at all times?

    If so you can either create a Personal Macro Workbook (Personal.xls), if you don't already have one, and store it in there or save the workbook as an Add-In.

    If you need more info post back.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    09-09-2010
    Location
    Haugesund, Norway
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: how to run macro from active workbook, without opening source workbook??

    Hi Domski,

    I have created macro in template (f.e. template.xlsx) workbook as a form that needs to be filled out. And when it is filled out need to save this file with different name (f.e. 1111.xlsx). But after when f.e. I need to change something on file 1111.xlsx when I push that button that it is assigned to macro, template.xlsx file opens and macro runs from that one
    I have assigned that macro to hot-keys as well (Ctrl+w) and when I pressing it, macro runs correct (from file 1111.xlsx). So what is different between hot-keys and the button that I have assigned that macro to?

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: how to run macro from active workbook, without opening source workbook??

    You can't, AFAIK. The button will always refer to a specific file.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: how to run macro from active workbook, without opening source workbook??

    You could programatically create a menu to run the code instead:

    http://spreadsheetpage.com/index.php..._custom_menus/

    Dom

  6. #6
    Registered User
    Join Date
    09-09-2010
    Location
    Haugesund, Norway
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: how to run macro from active workbook, without opening source workbook??

    thanks for your reply. I will try that...

  7. #7
    Registered User
    Join Date
    09-09-2010
    Location
    Haugesund, Norway
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: how to run macro from active workbook, without opening source workbook??

    Hi Domski,

    in your link there is written that this code is not working on excel2007 and i'm using it..
    But what about those add-ins..? How to save it as add-in?

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: how to run macro from active workbook, without opening source workbook??

    If the code is attached to a template I don't think the add-in route is what you require.

    Here's some info on adding options to the ribbon in 2007+

    http://www.rondebruin.nl/ribbon.htm

    Dom

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: how to run macro from active workbook, without opening source workbook??

    In some ways 2007 is easier because you can add ribbon customisations that are specific to that file - that way the button that is present will always refer to the code in the active workbook.

  10. #10
    Registered User
    Join Date
    09-09-2010
    Location
    Haugesund, Norway
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: how to run macro from active workbook, without opening source workbook??

    thanks a lot guys, i'm working with that now. Will see what I get..

+ 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