Link to home
Create AccountLog in
Avatar of thandel
thandel

asked on

Follow Link not working

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?

Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Do the non working users have Acrobat Reader installed ?

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

ET
Avatar of thandel
thandel

ASKER

Yes the computer does and if I open windows explorer to the folder I can open the PDF without issue.
What happens if you use:

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

?

mx
Avatar of thandel

ASKER

"Invalid procedure call or argument"
Yeah ... ignore that post.  I was thinking of something else.

Are the References all exactly the same on each system ?
mx
Avatar of thandel

ASKER

References as in the file/link to be opened?  Yes all the same.
Avatar of thandel

ASKER

Yes they are.
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)
Avatar of thandel

ASKER

No sign what so ever... just nothing happens, no error to attempt for Adobe to open.
Avatar of thandel

ASKER

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.
"its opens but appears to close it quickly.."
Does Acrobat appear in Windows Task Manager - remain ?

mx
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)
Avatar of thandel

ASKER

No Acrobat.exe starts but then terminates in Task Manager.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of thandel

ASKER

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)
I posted Shell Execute above :-)  the mvps.org link ...

mx
Avatar of thandel

ASKER

LOL!    (Any suggestions about the use of variables in your shell solution?)
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
Avatar of thandel

ASKER

Thanks forgot about the space.... take care.
ok ... try not to get too spaced out ...
Avatar of thandel

ASKER

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?
"having to hard code in the program path."
You mean this: "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe "
?
Avatar of thandel

ASKER

Yes I'm affraid that some computers may have a different version of Adobe and then a different folder for the executable.
I'm sure there is an API call that will return the installed folder of any app ...

mx
Avatar of thandel

ASKER

Thanks, this is getting more complicated.... I need to look into why the folllowhyperlink is not working.  Thank you.
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
Avatar of thandel

ASKER

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.
Avatar of thandel

ASKER

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.