Allen Browne's GoHyperlink -Question

magster06

Registered User.
Local time
Today, 12:17
Joined
Sep 22, 2012
Messages
235
Has anyone used Allen Browne's GoHyperlink?

If so, I was wondering if you had an issue with PDF's and Word docx's opening in the background of your Access database and were you able to correct this behavior?
 
Hello magster06, I have not used the GoHyperlink function, but was just curious, what is the issue you are facing?
 
Hi Paul,

The code works in opening the links stored in my table. The problem is that when the file to be opened is either a PDF or Word docx, then the files open in the background. So, I have to click on the open file to move it into the foreground.

If the file is a .txt file, then it will open in the foreground as it should.
 
I have not used Allen's code but I use the following code to view an attachment .docx or PDF etc. This displays the attachment in the foreground. The user selects the attachment using a combo box based on the category of the previous combo box. Note, Me!select_attach.Column(6) is the location of the attachment stored in a table with a data type Hyperlink.


Code:
'***********************************************************
' view the selected attachment
' ***********************************************************
Private Sub attachment_view_Click()
On Error GoTo Err_attachment_view_Click
Dim ctl As CommandButton
 
    Set ctl = attachment_view
    With ctl
        .HyperlinkAddress = Me!select_attach.Column(6)
        .Hyperlink.Follow
    End With
 
Exit_attachment_view_Click:
    Exit Sub
Err_attachment_view_Click:
    MsgBox Err.Description
    Resume Exit_attachment_view_Click
End Sub
 
Poppa Smurf,

Thank you for your response!

The reason I was trying to use the "GoHyperlink" code was due some inherit issues with "FollowHyperlink".

Here is a snippet from Allen Browne's site:

The GoHyperlink() function (below) performs the same task as FollowHyperlink(), with improved control over the outcome. Like FollowHyperlink, you can use it to:
  • Open a browser to a webpage (http:// prefix)
  • Send an email (mailto: prefix)
  • Open a file, using the program registered to handle that type (Word for .doc, Notepad for .txt, or Paint for .bmp, etc.)
Why a replacement?

FollowHyperlink can be frustrating:
  1. Security warnings may block you, or warn you not to open the file (depending on file type, location, Windows version, permissions, and policies.)
  2. Files fail to open if their names contains some characters (such as # or %.)
  3. Errors are generated if a link fails to open, so any routine that calls it must have similar error handling.
GoHyperlink addresses those frustrations:
  1. It prepends "file:///" to avoid the most common security warnings.
  2. It handles special characters more intelligently.
  3. Errors are handled within the routine. Check the return value if you want to know if the link opened.

Again, thank you for your response and I will keep your code incase I dont get things worked out.
 
How about using an API?? Allen Browne's code does eventually use the FollowHyperlink method which seems to have the problem of focusing.. I found THIS.. Hope this helps..
 
Paul,

I did see this code a while back and then forgot about it. I'll give it a try, thanks!
 
Ok, I am a dummy! I cannot figure out how to call the Private Declare Function apiShellExecute of the API code from the link above.

I have tried:

Call modapiOpenFile.apiShellExecute
modapiOpenFile.apiShellExecute
apiShellExecute(Me.FilePath)
apiShellExecute()

I am trying to call the function in the Click event of the textbox which resides in a subform.
 
The Declaration part should go on top.. Just below the Option Compare Database and Option explicit statements.. To call the function you have to use this...

Code:
'***************Usage Examples***********************
'Open a folder:     ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app:    ?fHandleFile("mailto:dash10@hotmail.com",WIN_NORMAL)
'Open URL:          ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
'Handle Unknown extensions (call Open With Dialog):
'                   ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
'Start Access instance:
'                   ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
'****************************************************
 
The Declaration part should go on top.. Just below the Option Compare Database and Option explicit statements..

Yes, I had this part. For some reason I was thinking that I had to call the Private Declare Function apiShellExecute.

Obiviously I cannot read very well, because when you pointed out the "usage examples", then it was like "how did I miss that".

Anyway, after seeing it work, it is not what I am exactly looking for.

Thanks again Paul! as usual - you are of great help!
 
Obiviously I cannot read very well, because when you pointed out the "usage examples", then it was like "how did I miss that".
We all have one of those days.. :) I would not worry about that..

Anyway, after seeing it work, it is not what I am exactly looking for.
Thanks again Paul! as usual - you are of great help!
Glad to have helped (???!!) Why is this method not suitable, if you don't mind me asking.. IMHO, this seems to open the doc/web/folder and also set the focus.. Or am I missing something?
 
Why is this method not suitable, if you don't mind me asking

Because I am an idiot! It just dawned on me to place my control after the fHandleFile... "fHandleFile(Me.txtFilePath,WIN_NORMAL)", and it works like a charm.

Thanks for making me look at the code again!
 
Ha ha.. That's alright magster06.. Glad you have it sorted.. :)
 

Users who are viewing this thread

Back
Top Bottom