Forum Discussion
Excel VBA and starting URL by clicking Shapes ???
- Apr 17, 2023I think I found the cause for starting in SafeMode - if you start FireFox (or any other browser, I think) while pressing the SHIFT-key the browser is FORCED to start in SafeMode ... that's my problem !
I have to choose another key to press when I want the users to open the link !
I want to use THE DEFAULT browser and NOT Edge ... in my case I use Firefox but it should be posible to just reference 'the default browser' - rigth ?
If you want to open the URL in the default browser for each user, you can use the FollowHyperlink method of the Application object instead of using the Shell function.
Here’s an example:
Sub OpenURL(URL As String)
Application.FollowHyperlink URL
End Sub
This code uses the FollowHyperlink method to open the URL in the default browser for the current user. You can call this function from your findLinkTilVielsen subroutine like this:
Public Sub findLinkTilVielsen(Sh As Shape)
If Trim(Sh.Hyperlink.Address) = "" Then
visFejlMeddelelse "No link is provided !"
Else
On Error GoTo notOK
OpenURL Sh.Hyperlink.Address
GoTo goAhead
notOK: On Error GoTo 0
visFejlMeddelelse "Link is corrupt !"
goAhead:
End If
End Sub
This should open the URL in the default browser for the current user, even if the browser is not already running.
I hope this helps!
I know I don't know anything (Socrates)
- keldsorApr 17, 2023Brass Contributor
???? I don't get you ... I see NO FollowHyperlink in Application !
But I must admit you CAN type it AND compile it without errors, but it wont run - it reports:
Run-time error 438
Object doesn't support this property or method
It seems like I have to use this - it works like I want to:ActiveWorkbook.FollowHyperlink Sh.Hyperlink.Address & "#" & Sh.Hyperlink.SubAddress
UPDATE:
No, this last code change didn't do it either - I still get this message with SafeMode or RESET when the browser is NOT running !
- keldsorApr 17, 2023Brass ContributorI think I found the cause for starting in SafeMode - if you start FireFox (or any other browser, I think) while pressing the SHIFT-key the browser is FORCED to start in SafeMode ... that's my problem !
I have to choose another key to press when I want the users to open the link !