why doesnt followhyperlink open website + shell syntax solution explanation

excellol

New Member
Joined
May 5, 2020
Messages
21
Office Version
  1. 2019
Platform
  1. Windows
1) this works:
Code:
thisworkbook.FollowHyperlink "https://www.google.com"
(remove the space after h)

but not this:
Code:
ThisWorkbook.FollowHyperlink "https://www.bi.go.id/en/statistik/indikator/IndONIA.aspx"

instead i got either one of these errors:
1624890226515.png

1624890935409.png


why is this so? both are normal websites so theoretically it should work?


2) i found this solution on stackoverflow which is able to open my website
Shell "explorer ""Indicator"""

could u explain the syntax to me? i tried googling for the shell syntax explanation but they werent helpful for my context
what does 'explorer' refer to? im sure that it isn't explorer.exe, as the code opened the website in my default browser which is firefox
why are there double quotes ("") for the website?
lastly, i used the shell code above for each of the 4 websites that i want to open. however, the websites did not open in the order of the shell code. is there a way to make them open in order?

for eg
Shell "explorer ""website1"""
Shell "explorer ""website2"""
Shell "explorer ""website3"""

firefox opened websites 1 and 3 followed by website 2
 
Last edited by a moderator:
It’s the variable that has the URL in, yes.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Because you need to concatenate another quotation mark onto the end of the URL.
 
Upvote 0
just to make sure if i understood the code. vba interprets this code
Rich (BB code):
Shell "explorer """ & add & """"
as Shell "explorer "add""

am i right?
 
Upvote 0
No - replace add with the URL that was assigned to add.
 
Upvote 0
i understand that add is the variable with the url stored in it.

then comes my next question:

Rich (BB code):
add ="http://www.mrexcel.com"

since the url in the add variable already is surrounded with quotation marks, the final version of the code would be
Rich (BB code):
Shell "explorer ""http://www.mrexcel.com"""
where the actual url is surrounded by double quotation marks. am i right?
 
Upvote 0
The text in the add variable is not surrounded by quotation marks. The quotes in this line:

VBA Code:
add = "http://www.mrexcel.com"

are there to tell the compiler that it's a literal string, they are not part of the actual text. That's why the next code line has to add actual quotes around the text value of the variable. You might find it less confusing to use Chr(34) to create a quotation mark like this:

VBA Code:
Shell "explorer " & Chr(34) & add & chr(34)
 
Upvote 0

Forum statistics

Threads
1,214,848
Messages
6,121,917
Members
449,055
Latest member
KB13

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