+ Reply to Thread
Results 1 to 12 of 12

Thread: Calling a macro without coding in the worksheet

  1. #1
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Calling a macro without coding in the worksheet

    I'm not quite sure what it is I'm working with here. I have recently inherited a masterpiece macro from someone I am replacing at work. The macro runs beautifully, but there are complexities that exist because I have no idea how it was originally written. I had an idea to improve on the macro, and have the code now to implement into the macro but there's a rub... I can't figure out how to call my macros with their respective hotkeys like the existing one does already.

    The structure of the macro is such that once it has been opened, it populates any instance of excel that's open and won't shut down until all instances of excel are closed. Ctrl+Shift+B will run the macro in any window of excel that you happen to be on. I've learned how to use an application.onkey within the workbook tab of VBA editor, but I have to copy the application.onkey code to each new sheet I open and save in order for the macro to work in the newly opened sheet.

    Any idea of where I'd look to find the coding on this master macro that I'm dealing with in order to implement more macro-calling code? I hope this makes sense, as I'm spinning my wheels in air now...

    Thanks in advance for the help, and apologize for the length of the explanation.
    Last edited by soran2484; 08-18-2010 at 03:11 PM. Reason: solved

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,226

    Re: Calling a macro without coding in the worksheet

    Perhaps the code is in the PERSONAL.XLS workbook. You could do the same to put in a macro that would then be available to all workbooks.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Calling a macro without coding in the worksheet

    I'm having no luck identifying where my PERSONAL.XLS file is. The file itself is an xla, and once you have opened it, it shows up on my VBA editor as its own project. I've saved a public application.onkey sub series into it, but that's not the ticket.

    I've written the macros into the end of the master macro, but can't figure out how to call them with the hot keys I desire. There is nothing apart from what I've put into the workbooks in VBA editor to call the macros that originally existed. Any ideas on how/where I may find the personal.xls file to verify whether that is or isn't the issue? I've done a system search for personal.xls with search results coming back empty.

    Thanks again your help Jerry

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Calling a macro without coding in the worksheet

    In XP, Personal.xls (if one exists) lives in C:\Documents and Settings\<username>\Application Data\Microsoft\Excel\XLStart\

    If you don't see it as a project in the VBE, you don't have one.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Calling a macro without coding in the worksheet

    Takes me back to square one.

    If you wanted to write an xla file, that when opened went effective in all workbooks of excel, how would you go about it?

    I'm flat out confuzzled

  6. #6
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Calling a macro without coding in the worksheet

    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Calling a macro without coding in the worksheet

    Thanks for the links. I'll get to reading, and report back with my findings

  8. #8
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Calling a macro without coding in the worksheet

    Good information on xla's, but I'm still not understanding where to code in the shortcut keys. Any help on how to reprogram shortcut keys in xla's? I've explored the onkey function from the workbook idea, but that doesn't persist to all open workbooks. I know it has to be possible because I have an xla in my hands that works just that way. Is there anything apart from VBA Editor that is used to modify xla's?

  9. #9
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Calling a macro without coding in the worksheet

    To assign a shortcut to a sub that takes no arguments,

    o Alt+F8 to open the Macros dialog

    o Type in the name of the sub (the Run buttons and others will enable)

    o Press Options and follow your nose from there
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Calling a macro without coding in the worksheet

    Wow that was simpler than I could have imagined!

    A hopefully simple followup question:

    If I want to use multiple keys apart from CTRL, for instance Shift+CTRL+ALT+a, where can I modify that? The Alt-F8 menu only gives me CTRL + as an option...

    Thanks Shg

    (Looks like I can actually do CTRL + Shift by holding down shift and then hitting the key, but Alt isn't working)
    Last edited by soran2484; 08-18-2010 at 03:08 PM. Reason: discovery

  11. #11
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Calling a macro without coding in the worksheet

    Ctrl and Ctrl+Shift are all you get.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Registered User
    Join Date
    08-18-2010
    Location
    Orem, UT
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Calling a macro without coding in the worksheet

    Fair enough. Thanks so much for the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0