+ Reply to Thread
Results 1 to 9 of 9

Macro run by shortcut key malfunctions

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Macro run by shortcut key malfunctions

    If I run Sub pmOpenIt() from F5 key, fine. From alt-F8 and run, fine. I can even type call pmOpenIt() into debug window and run, fine.

    But using its option-set Ctrl-Shift-Q causes it to run through the Workbooks.Open, and no further.

    So that I can rule out corruption, can someone reproduce? It chokes in XL2003 and XL2007 here
    Option Explicit
    Sub pmOpenIt()
        Application.StatusBar = "running"
        Debug.Print "0 "
        Workbooks.Open "c:\delme.xls", 0
        Debug.Print "1 "
        Application.StatusBar = "Done."
    End Sub
    Last edited by Oppressed1; 10-15-2013 at 08:11 PM. Reason: Removed superfluous/confusing extra word "open"; changed Ctrl-Alt-Q to Ctrl-Shift-Q
    Chip, if you can read this, you're STILL making the world a better place with your immeasurably valuable gifts. Every week, you continue to help me (and untold numbers of others) tremendously. Practically no alternative outlets can match your effectiveness, even over the vast number of topics you demystify and empower usage of. You were, and still are, amazing.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,683

    Re: Macro run by shortcut key malfunctions

    According to Microsoft's documentation

    On the Tools menu, point to Macro, and then click Macros.
    In the Macro name box, enter the name of the macro you want to assign to a keyboard shortcut key.
    Click Options.
    If you want to run the macro by pressing a keyboard shortcut key, enter a letter in the Shortcut key box. You can use CTRL+ letter (for lowercase letters) or CTRL+SHIFT+ letter (for uppercase letters), where letter is any letter key on the keyboard. The shortcut key cannot use a number or special character, such as @ or #.

    Note: The shortcut key will override any equivalent default Microsoft Excel shortcut keys while the workbook that contains the macro is open.

    If you want to include a description of the macro, type it in the Description box.

    Click OK.
    Click Cancel.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Macro run by shortcut key malfunctions

    That's very interesting but I don't know what that has to do with my question. I know how to run a macro, at least 4 different ways described above (and I wouldn't be surprised if few experts knew the 3rd way). The issue I described is that it stops during or after the .Open. If you test that simple code, either one debug.print runs or two do; either one .statusbar runs or two do. I'm looking for confirmation of reproducibility or not.

    One thing that may have been obvious but I didn't mention: create c:\dummy.xls from a new clean Ctrl-N workbook, close it, and then run the code above from any other WB than dummy.xls.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,683

    Re: Macro run by shortcut key malfunctions

    I posted because you indicated that your shortcut key was Control + Alt + Q. In the MS documentation it refers to shortcut keys as Control + letter or Control + Shift + Letter, but no use of the Alt Key. I thought this might be part of your issue.

  5. #5
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Macro run by shortcut key malfunctions

    Yikes, my stupidity. I should have typed Ctrl-Shift-Q - I'll try to edit that. Sorry, and I deserved the level 1 treatment for my sloppiness!! However the question remains.

    Can anyone reproduce, or signify negative reproduction?
    Last edited by Oppressed1; 10-15-2013 at 08:12 PM.

  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: Macro run by shortcut key malfunctions

    Workbooks.Open "c:\delme.xls", 0
    What's the 0 for?
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Macro run by shortcut key malfunctions

    Quote Originally Posted by shg View Post
    Workbooks.Open "c:\delme.xls", 0
    What's the 0 for?
    It eliminates the nag of answering the message box asking whether to update links. In my example, it's superfluous. (But if I was wrong on it being inert here, that would be horrid for everyone. You'd have to test for existence of linked files before even using that parameter.)

    http://msdn.microsoft.com/en-us/libr.../ff194819.aspx (scroll down to see that parameter's details)

  8. #8
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Macro run by shortcut key malfunctions

    Good catch shg; http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx has different values for that parameter for different Excel versions!! GRRR!

    Anyway changing 0 to 2 for Excel 2003 didn't change anything for 2003 or 2007. It still runs the Open, and no further, and only when run from a shortcut key (runs perfect any other way).

  9. #9
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Macro run by shortcut key malfunctions

    I'll take from the silence that no one either reproduced it or failed to, so just in case anyone didn't try it because they thought it would take more than one minute, the steps would be
    - Open Excel.
    - Ctrl-N
    - Save as c:\delme.xls
    - Ctrl-F4
    - Ctrl-N
    - alt-F11
    - insert a module
    - Paste the 8 lines of code there from first post above.
    - Set Ctrl-shift-Q (or Ctrl-shift-T or whatever) as shortcut to that sole sub, pmOpenIt
    - Run the shortcut
    - Bonus, change ",0" to ",2" which may be significant for some XL versions, and retry

    In my case, the second debug.print and second .statusbar fail if I invoke with a shortcut, but succeed if I start the code without a shortcut; does anyone else? Does anyone else *not*?

    If I still hear nothing, I'll assume that means no one reproduces, and operate as if I have a corrupt file or installation, as deeply sickening as either would be.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 06-09-2013, 07:21 PM
  2. [SOLVED] OpenFileDialog box malfunctions
    By hometech in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 03:18 AM
  3. Responses hampered by site malfunctions...??
    By HuskerBronco in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2008, 11:55 AM
  4. Workbook only malfunctions on a single PC
    By Crypto in forum Excel General
    Replies: 3
    Last Post: 01-10-2006, 07:55 PM
  5. Macro shortcutsWhen you are assigning a keyboard shortcut to a macro?
    By JudithJubilee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2005, 04:06 AM

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