Single key shortcut for stepping over

Hi Experts,
Is there a way to use a single keyboard key to perform the following?
Shift-F8      Step over the line by running the procedure on the current line without going into it and stepping through each line
Thanks
LVL 6
bfuchsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Do you want to do this while debugging?
bfuchsAuthor Commented:
hi,
yes.
Thanks,
Ben
NorieAnalyst Assistant Commented:
As far as I know there is no single key shortcut for that but what you could is set a breakpoint on the next line of code and then press F5.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Martin LissOlder than dirtCommented:
In VB6 which is very similar to VBA the shortcut for stepping through was F8 (without Shift). If however you are using a Windows VM like Parallels on a Mac like i am, you may have to use Shift+F8.  You might however be able to set up a Windows shortcut for what you want to do. See my article on debugging for more information.
bfuchsAuthor Commented:
Hi,
you could is set a breakpoint on the next line of code and then press F5.
I've constantly been debugging lot of code and not interested in stepping thru all the sub functions that are being called by the function I'm looking at, would either have to hold down the shift key all the time while pressing f8 key or perhaps find a way to have windows know that a certain key should be considered same as pressing shift+f8, that could be only while debugging or would not mind if this will be the behavior at all times...
You might however be able to set up a Windows shortcut for what you want to do
Where do you explain this in the article?

Thanks,
Ben
Martin LissOlder than dirtCommented:
I'm sorry that I gave the impression that my article talked about creating shortcuts; it doesn't. In any case I don't know what version of Windows you are using but maybe this article which describes how to do it Windows 10 will help you.
bfuchsAuthor Commented:
Hi,
I'm using Windows 7,
Saw this on google, no idea what is it talking about...
If you want take it even further, create keyboard shortcuts for quick access to Windows 7 settings. Step 1: Right-click on one of the shortcut icons you just created and select "Properties." Step 2: In the "Shortcut key:" field, type a key combination to use as a keyboard shortcut.
Thanks,
Ben
NorieAnalyst Assistant Commented:
Ben

When you use F5 code execution will continue, without any stepping, until the next breakpoint.
bfuchsAuthor Commented:
Hi Norie,

I do want be stepping thru all lines belonging to the function I am looking at, just want avoid entering sub functions, see foe example
    i = UnZip(sDownloadFolder & sLastFile, sDestinationFolder, False)
    
    If i = 0 Then
        sDestinationFolder = "C:\Application\"
        
        If Dir(sDestinationFolder & NewestFile(sDestinationFolder, "*." & sExt)) <> "" Then
            If Dir(sDestinationFolder & "Tables." & sExt) <> "" Then
                Kill sDestinationFolder & "Tables." & sExt
            End If
            Name sDestinationFolder & NewestFile(sDestinationFolder, "*." & sExt) As sDestinationFolder & "Tables." & sExt
        End If
    End If

Open in new window

I want step into all those lines, however Unzip and NewestFile which are other functions I dont step into, and prefer not having to use two keys all the time (Shift+F8).

Most of the times I end up entering unintentionally those functions, then have to use other key combinations for stepping out...

Thanks,
Ben
Martin LissOlder than dirtCommented:
You can use conditional compilation as described in this article of mine to do what you want. The article is written for VB6 but using the technique for VBA is very similar. Basically you go to Visual Basic, right-click on the VBA Project in the 'Project - VBAProject' window, select 'Project Properties' and enter something like what is shown here in the 'Conditional Compilation Arguments:' box.
2018-12-04_12-20-47.pngAs long as Testing (or whatever you call it) is 1, then the following code will bypass the calling of SomeSub.
Sub test()
#If Testing Then
    ' Don't do anything
#Else
    SomeSub
#End If
End Sub
Sub SomeSub()
    MsgBox "hello"
End Sub

Open in new window


In your case that code could be simplified to this
Sub test()
#If Not Testing Then
    SomeSub
#End If
End Sub

Open in new window

I've attached a small sample project.
29128192.xlsm
bfuchsAuthor Commented:
Hi Martin,
then the following code will bypass the calling of SomeSub.
Just to clarify, I'm not looking to bypass the executing those sub functions, just to bypass stepping thru the code line by line, exactly what shift+f8 does.
And this is from your first article above...
Step Over is similar to Step Into except that as its name implies it will step over or skip the current line. Note that it doesn't skip the execution of the line, only the stepping through. In other words if the current line is a call to a long Sub that you don't really care about, stepping over will execute the call and then pause at the line following the call.
Thanks,
Ben
Martin LissOlder than dirtCommented:
The only thing that I can suggest is that if you find yourself in one of the subs that you don't want to step through, click the Debug menu's 'Step Out' button.

2018-12-04_14-16-19.png
NorieAnalyst Assistant Commented:
Have you tried setting breakpoints and using F5?

For example in the code you posted you could put breakpoints on line 1 and line 3.

You could then step through the code until you reach line 1 and then press F5 to skip to line 3.
bfuchsAuthor Commented:
Hi experts,

Have you tried setting breakpoints and using F5?
Yes, I use that occasionally when only want to start debugging from a certain point.
For example in the code you posted you could put breakpoints on line 1 and line 3.
Well normally I'm looking at much larger code, would not be practical to look thru the entire code to find where there is a function called and set there a breakpoint...
click the Debug menu's 'Step Out' button.
As mentioned, this is what I'm currently doing...

I would really prefer the creating shortcut approach that Martin mentioned above, wondering if its doable in windows 7.
 

Thanks,
Ben
Martin LissOlder than dirtCommented:
Assuming you can create a shortcut in Win7, what would it emulate? If it's Shit+F8 and you assign it to, say, F9, how would that prevent you from wandering into the subs you don't want to step through? I think you're asking for something to step through code line by line but intelligent enough to step over certain subs and that's not possible.
NorieAnalyst Assistant Commented:
Ben

You only occasionally use breakpoints?

If you used breakpoints a bit more, along with F5, then you should be able to skip over code you don't want to step through easily.

As for searching through code for function calls, why not put a breakpoint on the function itself?
bfuchsAuthor Commented:
If it's Shit+F8 and you assign it to, say, F9, how would that prevent you from wandering into the subs you don't want to step through?
No, I just need something to simulate the exact same behavior as shift+f8, F9 is fine.
Can you provide instructions for accomplishing that?
Thanks,
Ben
Martin LissOlder than dirtCommented:
So you want to F8, F8, F8,...F8 until you get to a certain sub and then press F9 and have it step over, right? If so that is exactly what you can do by pressing the Step Over item instead.

Anyhow here's a Win7 article that may help.
bfuchsAuthor Commented:
why not put a breakpoint on the function itself?
Not getting it.
If I have a function that is 100 lines long and have within a dozen of calls for other functions, do I have to look for them thru the entire function and place a dozen of breakpoints?
what exactly will that accomplish.
Thanks,
Ben
bfuchsAuthor Commented:
So you want to F8, F8, F8,...F8 until you get to a certain sub and then press F9 and have it step over, right?
Not either, I just want to use f9 all the time...no switching keys and no using two keys, very simple...
Thanks,
Ben
bfuchsAuthor Commented:
@Martin,
That link explains how to create a shortcut to particular application. see below
Right-click the desktop shortcut of the application, then click Properties > Shortcuts.
Thanks,
Ben
Martin LissOlder than dirtCommented:
Not either, I just want to use f9 all the time...no switching keys and no using two keys
That's not possible.
bfuchsAuthor Commented:
That's not possible.
So you're saying its not possible to have F9 behave like Shift+F8?
Thanks,
Ben
bfuchsAuthor Commented:
Just to clarify, currently if I use Shift+F8 all the time while debugging, it does what I want.
My goal here is to avoid constantly having to use a combination of two keys.
Thanks,
Ben
bfuchsAuthor Commented:
Actually I saw the following on the web
Step 2: Start the Keyboard wizard, and change the assignments
Open the Keyboard item in Control Panel. ...
On the Key Settings tab, select the key that you want to change.
To change the command or the program assignment, click Configure. ...
Select the appropriate options, and then follow the instructions
This looks like something we are trying to accomplish.
The problem is that there is no settings tab under my keyboard item...only tabs I see are speed and hardware-:(
Thanks,
Ben
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I don't know where you found that, but it is nonsense. The default control panel keyboard wizard does not have that ability to assign keys to applications, and even if, it would be unable to assign actions inside of applications.

The following is what comes into my mind:
  • Caps Lock might apply to F8 too (making it Shift-F8)
  • With AutoHotkey or AutoIt you can write up scripts which are triggered by a key (e.g. NumPad *), and then send a different key to the current active or particular application window.
  • Some keyboard driver software allows for using special keys  - media, volume, home page aso. -  to send other keys.
  • Same for some mouse drivers.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bfuchsAuthor Commented:
@Qlemo,\
Caps Lock
might
apply to F8 too (making it Shift-F8)
That would have been a good idea, just a pity it does unfortunately not work-:(
Re the other options, would need some helping hands here...-:)
Thanks,
Ben
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
The latter two options need to be checked by yourself. If you use Logitech gear, look into its setup app.
Regarding AutoHotkey I can only tell it exists, but I do not use it myself.
bfuchsAuthor Commented:
@Qlemo,
I installed AutoHotKey, started looking into, but could not figure out how to do it.
It looks like you need to write a script in order to accomplish that, there is no GUI helping you.
Any idea how to write this command in a script?
See attached what I tried and error I'm getting.
Thanks,
Ben
Untitled.png
bfuchsAuthor Commented:
Actually the following types F8 when I press F9.
F9::send +F8

Open in new window

How can I change it to refer to shift+f8?
Thanks,
Ben
bfuchsAuthor Commented:
I got it
F9::send {shift}+{F8}

Open in new window

Thanks,
Ben
bfuchsAuthor Commented:
Thanks to all participants!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.