Application.FollowHyperlink (1 Viewer)

Dave E

Registered User.
Local time
Yesterday, 21:32
Joined
Sep 23, 2019
Messages
104
Hi code-writers

I have a piece of code to use Application.FollowHyperlink strURL command, where strURL is the search word(s) entered by the user. It works well but not as I hoped.
At the moment, the code opens Google search page and enters the search words into the searchbox. What I would like is to have the code to open Google, insert the search word(s) and then to go one step further and open the links to the pages found by Google. I've tried adding '+ Chr(13)' to the strURL and various permutations to no avail.

Does anybody have any ideas about how to achieve it?

Regards

DaveE
 

Dave E

Registered User.
Local time
Yesterday, 21:32
Joined
Sep 23, 2019
Messages
104
Thanks for the link but it's not what I'm looking for. I want to be able to use the Access database VBA code to trigger a Google search after the webpage had been opened and the search text inserted, which includes a trigger added to make Google start the search.
 

Dave E

Registered User.
Local time
Yesterday, 21:32
Joined
Sep 23, 2019
Messages
104
So, I have a plant name that I have from a table.
I can open a Google page from VBA and insert the plant name.
And there it stops. If I hit the Enter button, Google finds all the links associated with the plant name but I would like the Google search to start automatically without the help of my Enter key.
Is there a way to start the Google search from VBA?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:32
Joined
Oct 29, 2018
Messages
21,467
Hi. Can you show us your FollowHyperlink code? I just gave it a try, and it seems to work for me using something like:

Application.FollowHyperlink "https://www.google.com/search?q=" & keyword
 

Dave E

Registered User.
Local time
Yesterday, 21:32
Joined
Sep 23, 2019
Messages
104
Hi,
The code I'm using gets the Google screen open and the LatinName inserted but goes no further.
I was hoping to open the Google screen, insert the Latin Name and get the search started.

The code I'm using is -

Code:
Dim Tempstr As String, lenstr As Integer, J As Integer, strURL As String

Tempstr = Forms!MainOptions!MainView!LatinName
lenstr = Len(Tempstr)
For J = 1 To lenstr
    If Mid(Tempstr, J, 1) = " " Then
        Mid(Tempstr, J, 1) = "+"
    End If
Next J

strURL = "https://www.google.co.uk?hl=en&q=" & Tempstr

Application.FollowHyperlink strURL 'Navigate to the URL

Be grateful for any help

Dave E
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:32
Joined
Oct 29, 2018
Messages
21,467
Hi,
The code I'm using gets the Google screen open and the LatinName inserted but goes no further.
I was hoping to open the Google screen, insert the Latin Name and get the search started.

The code I'm using is -

Code:
Dim Tempstr As String, lenstr As Integer, J As Integer, strURL As String

Tempstr = Forms!MainOptions!MainView!LatinName
lenstr = Len(Tempstr)
For J = 1 To lenstr
    If Mid(Tempstr, J, 1) = " " Then
        Mid(Tempstr, J, 1) = "+"
    End If
Next J

strURL = "https://www.google.co.uk?hl=en&q=" & Tempstr

Application.FollowHyperlink strURL 'Navigate to the URL

Be grateful for any help

Dave E
Hi Dave. Thanks for showing us your code. Try replacing this line:
Code:
strURL = "https://www.google.co.uk/search?hl=en&q=" & Temstr
Hope that helps...
 

Dave E

Registered User.
Local time
Yesterday, 21:32
Joined
Sep 23, 2019
Messages
104
Thanks a lot for that...it worked!!
It looks like I was so close, but not close enough.

Very much obliged to you for your help.

Dave E
 

Sun_Force

Active member
Local time
Today, 13:32
Joined
Aug 29, 2020
Messages
396
Maybe you want to replace the loop with the following;
Tempstr = Replace ( Tempstr, " ", "+")

you can do the same task with one line instead of 6.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:32
Joined
Oct 29, 2018
Messages
21,467
Thanks a lot for that...it worked!!
It looks like I was so close, but not close enough.

Very much obliged to you for your help.

Dave E
Hi Dave. Glad to hear you got it sorted out. Good luck with your project.
 

Dave E

Registered User.
Local time
Yesterday, 21:32
Joined
Sep 23, 2019
Messages
104
Maybe you want to replace the loop with the following;
Tempstr = Replace ( Tempstr, " ", "+")

you can do the same task with one line instead of 6.
Thanks for that...I wasn't aware of the Replace command.
 

Users who are viewing this thread

Top Bottom