Solved follow hyperlink (1 Viewer)

murray83

Games Collector
Local time
Today, 09:51
Joined
Mar 31, 2017
Messages
728
have had a quick search and not sure why this isn't working, basic problem is

the hyperlink to follow will be different each time as its based on a choice from a combo box, which then populates a text box with the path which is in the column of the combo box but is hidden

so have made this a my code

Code:
Private Sub cmdGoTo_Click()

'the path as will be different each time so dimd it
Dim Path As String
Path = Me.Text5
    
'should open the file
Application.FollowHyperlink "Path"

End Sub

but keeps on not working as the path is some how not being passed to the hyperlink bit, it is in the path dim any help would be greatfull appreciated, cheers

see attached for my workings
 

Attachments

  • Daventry Digital Paperwork Archive.zip
    23.3 KB · Views: 78

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:51
Joined
Aug 30, 2003
Messages
36,125
Haven't looked at the sample, but you don't want quotes around the variable. It is being treated as literal text. Try:

Application.FollowHyperlink Path
 

vba_php

Forum Troll
Local time
Today, 03:51
Joined
Oct 6, 2019
Messages
2,880
Application.FollowHyperlink Path
and since the VBE doesn't know what it wants sometimes, and can get confused with itself from version to version, if that doesn't work, surely this will:

Code:
Application.FollowHyperlink(Path)
 

vba_php

Forum Troll
Local time
Today, 03:51
Joined
Oct 6, 2019
Messages
2,880
after looking at your file, you probably can't open it because it can't be parsed. the PATH has spaces in it. try renaming your files to something like this:
Code:
G:\GENERAL\STOCK\supplier_compliance\Digital_Archive\2020\03_Mar\16_03_2020\13675343.pdf
but then again, like I said before, VBA isn't the best so it could be another issue as well.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:51
Joined
Oct 29, 2018
Messages
21,467
Hi. I obviously couldn't test your code because I don't have those files in the same path, but I did modify your code slightly. Please give it a try and let us know how it goes. Cheers!
 

Attachments

  • Daventry Digital Paperwork Archive.zip
    24.6 KB · Views: 79

vba_php

Forum Troll
Local time
Today, 03:51
Joined
Oct 6, 2019
Messages
2,880
guys' code
Code:
Application.FollowHyperlink """" & Me.List0.Column(2) & """"
that does solve the issue of spaces too
 

murray83

Games Collector
Local time
Today, 09:51
Joined
Mar 31, 2017
Messages
728
Haven't looked at the sample, but you don't want quotes around the variable. It is being treated as literal text. Try:

Application.FollowHyperlink Path

sir, thanks i did this as suggested

Code:
Private Sub cmdGoTo_Click()

'the path as will be different each time so dimd it
Dim Path As String
Path = Me.Text5

'should open the file
Application.FollowHyperlink Path


End Sub

as i removed the speech marks from around Path and Bam it works, spaces an all

thanks to all who looked suggested as well, much appreciated
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:51
Joined
Oct 29, 2018
Messages
21,467
sir, thanks i did this as suggested

Code:
Private Sub cmdGoTo_Click()

'the path as will be different each time so dimd it
Dim Path As String
Path = Me.Text5

'should open the file
Application.FollowHyperlink Path


End Sub

as i removed the speech marks from around Path and Bam it works, spaces an all

thanks to all who looked suggested as well, much appreciated
Hi. Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom