'***********************************************************
' 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
The GoHyperlink() function (below) performs the same task as FollowHyperlink(), with improved control over the outcome. Like FollowHyperlink, you can use it to:
Why a replacement?
- 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.)
FollowHyperlink can be frustrating:
GoHyperlink addresses those frustrations:
- Security warnings may block you, or warn you not to open the file (depending on file type, location, Windows version, permissions, and policies.)
- Files fail to open if their names contains some characters (such as # or %.)
- Errors are generated if a link fails to open, so any routine that calls it must have similar error handling.
- It prepends "file:///" to avoid the most common security warnings.
- It handles special characters more intelligently.
- Errors are handled within the routine. Check the return value if you want to know if the link opened.
'***************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..
We all have one of those days..Obiviously I cannot read very well, because when you pointed out the "usage examples", then it was like "how did I miss that".
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?Anyway, after seeing it work, it is not what I am exactly looking for.
Thanks again Paul! as usual - you are of great help!
Why is this method not suitable, if you don't mind me asking