Sendkeys and macro shortcut key

jackms

New Member
Joined
Dec 28, 2005
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
I am a beginner Macro coder and was hoping someone can help me with this problem.

I have a macro that activates a specific Internet Explorer window (that's already open) and then uses SendKeys to type a URL in the address bar.

The problem is, i would like to assign a shortcut to the macro. But when I run the macro using the shortcut key, it's as if the Ctrl key is still pressed (so if, for example, I have SendKeys "p" - it opens up the Explorer print function, instead of just typing the letter p). If i run the macro using Tools,Macro... it works fine. Any suggestions?

This is the macro:

ssnText = Application.WorksheetFunction.Text(ActiveCell.Value, "000000000")

AppActivate Title:="yyyy"

Application.Wait Now() + TimeValue("00:00:01") ' Wait a sec (i got this from mrexcel)

SendKeys "%d" & "https://www.yyyy.com/searchssn.asp?SSN=" & ssnText & "{ENTER}"
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
jackms,
Why not just use the shell command to call explorer with the address?

Code:
Shell ("explorer ""http://www.mrexcel.com""")

HTH
Cal
 
Upvote 0
Thanks for replying.

Shell command opens a new browser window (i also tried using FollowHyperlink event - that also opens new window). Then I can't get the page I want because I'm not logged in to the website.

That's why I need to go to the web page from an already open browser where I've already logged in.
 
Upvote 0
After fooling around a bit more, i came up with the following solution.

I added the following line to the beginning of the macro:

VBA Code:
Application.Wait Now() + TimeValue("00:00:02")

I think this works becasue it allows time for the user to release the control key before Explorer is activated. It seems like if control key is still pressed at the time Explorer is activated, then the control key gets "stuck".

Not a perfect solution, but it works.
 
Last edited by a moderator:
Upvote 0
Solution

Forum statistics

Threads
1,214,409
Messages
6,119,339
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top