+ Reply to Thread
Results 1 to 5 of 5

Unclear definition of attribute for macro shortcut key combination

  1. #1
    Registered User
    Join Date
    09-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    20

    Question Unclear definition of attribute for macro shortcut key combination

    Hello All,

    Can anyone shed any light on the attribute setting of a macro shortcut key:

    Please Login or Register  to view this content.
    NOTE: The above example code line can be seen after exporting vba module and opening resulting .bas file in a text editor

    [QUESTIONS]
    1. What does the "\n14" in the above code mean? (is it like C code newline? if so why 14?)
    2. Where can I find out details about these Attribute settings i.e. is this defined anywhere? I would like to try to understand them more.


    [BACKGROUND]
    I created and tried to use a shortcut key combo to run a simple macro (MyMacro) in XL2010.
    The shortcut key combination Ctrl + Shift + S was assigned the macro header was updated with comments to indicate that the the shortcut was assigned.
    Also checked that this shortcut key combination was not used for any other assignment.
    When I tried to run the macro by shortcut keys it would not run. However, when I run the macro directly in VBE or in Excel Alt + F8 --> select MyMacro --> Run it would execute fine.
    I then exported the MyMacro module --> modified .bas file attribute code line see 1. below in text editor by deleting the \n14 from the Attribute line so that it looked like 2. below --> saved file --> imported back into original workbook and then the shortcut keys worked OK!!

    Ctrl + Shift + S shortcut doesn't work in case 1.
    1.
    Please Login or Register  to view this content.
    Ctrl + Shift + S shortcut now works in case 2!!
    2.
    Please Login or Register  to view this content.
    So I'd like to understand why it now works just by deleting the \n14 from the code line and the details of these Attribute settings for future reference.

    Thanks

    Nutty.
    Last edited by nuttyengineer; 07-14-2012 at 03:30 PM.

  2. #2
    Forum Contributor
    Join Date
    05-25-2012
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    194

    Re: Unclear definition of attribute for macro shortcut key combination

    Hi Nutty, I typically use a different approach for assigning macros to any key combination in the current workbook for excel;

    Please Login or Register  to view this content.
    Nonetheless, are you looking for something that will keep your keys assigned after the workbook is closed?

  3. #3
    Registered User
    Join Date
    09-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    20

    Re: Unclear definition of attribute for macro shortcut key combination

    Hi Medpack,

    Thank you for referring to the OnKey method of applying a shortcut to a macro.
    That will be useful in the future.

    Nonetheless, are you looking for something that will keep your keys assigned after the workbook is closed?
    I am more interested in understanding how the inbuilt Excel attributes settings work for shortcuts in this case.
    Been searching online but there is not much out there on this specific point. Hence my previous questions.
    Would be interesting to know if there are other hidden attributes which one could set.

    Nutty

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Unclear definition of attribute for macro shortcut key combination

    You could vary this a little bit:

    record several macros

    assign them to the keyboard S, shift-S, alt-s, ctrl-s, shift-ctrl-S, etc. respectively.
    Export the macros into .bas file.
    Compare the resulting strings.
    I think you might be able to deduce the underlying 'logic'/pattern.
    Last edited by snb; 07-16-2012 at 05:46 AM.



  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Unclear definition of attribute for macro shortcut key combination

    you can use VB_UserMemId to create default properties for your classes and to create an enumerator for your collection class. you can also change the instancing of a class to multiuse so that you can create it from a referencing project. (you can do that in the VBE too)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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.6.0 RC 1