We help IT Professionals succeed at work.

Follow Link not working

thandel
thandel asked
on
I have the following code works on some computer and on others it doesn't work... no errors just nothing happens.  Any ideas?

    Dim StrFilename As String
   
    StrFilename = "\\mv\public\Ocular\Chart.pdf"
    Application.FollowHyperlink StrFilename

I am running this code on a onclick event on a form... its working on most computer but not on all.  I'm not sure why.  I've checked security settings and they all seem the same (Low) and I've modified the registry to avoid the hyperlink warning.  Any suggestions?

Comment
Watch Question

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Do the non working users have Acrobat Reader installed ?

mx
Eric ShermanAccountant/Developer
CERTIFIED EXPERT

Commented:
Make sure the non working computers have a pdf reader (such as Adobe) installed and associated with .pdf file extensions by default.

ET

Author

Commented:
Yes the computer does and if I open windows explorer to the folder I can open the PDF without issue.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
What happens if you use:

Shell "\\mv\public\Ocular\Chart.pdf"

?

mx

Author

Commented:
"Invalid procedure call or argument"
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Yeah ... ignore that post.  I was thinking of something else.

Are the References all exactly the same on each system ?
mx

Author

Commented:
References as in the file/link to be opened?  Yes all the same.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Actually, VBA references ...

mx

Author

Commented:
Yes they are.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Is there any sign at all that the PDF reader is attempting to open the file?

Just searching on terms like "FollowHyperlink Problems", I've seen a few similar cases -- all with PDF files.

This person opted to use a Web Browser control instead of FollowHyperlink:

http://forums.techguy.org/business-applications/553491-access-vba-followhyperlink-pdf-document.html

(I personally have never had any trouble opening PDF files using the FollowHyperlink method)

Author

Commented:
No sign what so ever... just nothing happens, no error to attempt for Adobe to open.

Author

Commented:
Let me correct my last response... its opens but appears to close it quickly... something is happening very quickly but I can't tell if its Adobe or not.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
"its opens but appears to close it quickly.."
Does Acrobat appear in Windows Task Manager - remain ?

mx
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Did you look over the thread I linked to in my last comment (http:#a37078435)?

The author of that thread was experiencing exactly the same thing (no solution there - just a workaround)

Author

Commented:
No Acrobat.exe starts but then terminates in Task Manager.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
For that matter, ShellExecute would be a workaround:

http://access.mvps.org/access/api/api0018.htm

mx
Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007
Commented:
As a test , what happens if you do this:

For example, this works on my system
Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe  c:\DeleteTest.pdf", vbNormalFocus

So maybe : (adjust version/location of Acrobat if necessary - and you will probably need to use the Full UNC Path.  Which actually brings up a question - are the non working systems using a Mapped Drive letter?

Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe  \\mv\public\Ocular\Chart.pdf", vbNormalFocus

Author

Commented:
That worked.... thanks.  I can't figure out how to incoporate a variable:
Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" & StrFilename, vbNormalFocus
Didn't work.  How can I use a variable with your solution?

I just found another solution that I may use to its not path dependant

Function:

Public Declare Function ShellExecute Lib "shell32.dll" _
   Alias "ShellExecuteA" _
   (ByVal hWnd As Long, ByVal lpszOp As String, _
    ByVal lpszFile As String, ByVal lpszParams As String, _
    ByVal LpszDir As String, ByVal FsShowCmd As Long) _
    As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1

Module:
  nDT = GetDesktopWindow()
  nApp = ShellExecute(nDT, "Open", StrFilename, "", "C:\", SW_SHOWNORMAL)
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
I posted Shell Execute above :-)  the mvps.org link ...

mx

Author

Commented:
LOL!    (Any suggestions about the use of variables in your shell solution?)
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Well, are you going to use that or SE ?

Variable ... you need a Space after EXE and your variable:

Dim x
x = "c:\DeleteTest.pdf"
Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" & " " & x, vbNormalFocus
                                                                                                          ^^^^^^

OR

Dim x
x = "c:\DeleteTest.pdf"
Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe " & x, vbNormalFocus
                                                                                                       ^^

mx

Author

Commented:
Thanks forgot about the space.... take care.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
ok ... try not to get too spaced out ...

Author

Commented:
Well after further testing using the function opens ok but then if I select another file from a drop down, acrobate launches (nothing in task bar but can see in task manager) but nothing opens... I select the same file to open then it does this again... two attempts to get the file to open... crazy.

The only reliable code is via shell but I don't like having to hard code in the program path.  Any other ideas?
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
"having to hard code in the program path."
You mean this: "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe "
?

Author

Commented:
Yes I'm affraid that some computers may have a different version of Adobe and then a different folder for the executable.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
I'm sure there is an API call that will return the installed folder of any app ...

mx

Author

Commented:
Thanks, this is getting more complicated.... I need to look into why the folllowhyperlink is not working.  Thank you.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Yeah ... I hear you.  Guess we would have to be there on the hyperlink gig ...
In VBA, it's easy to get the installed folder for Access ...

I'll look around when I get a moment ...

mx

Author

Commented:
You know what I finally got working... I have the code execute the followhyperlink AND the shell code.... it works on all computers.... the funny part is only one PDF opens instead of the 2 expected by the repeated code.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Now THAT ... is Spaced ... out!

mx

Author

Commented:
Yea its working like a champ now on all computers.... I can't figure that one out.  Not even sure what made me think to try the 2 lines of code.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Double Down !

Explore More ContentExplore courses, solutions, and other research materials related to this topic.