AOB
Registered User.
- Local time
- Today, 11:50
- Joined
- Sep 26, 2012
- Messages
- 621
Hi guys,
I have a continuous subform of attachments which includes a command button for the user to open/view the attachment in question. It's fairly straightforward :
However I noticed I was getting a number of errors logged, specifically :
I got a bit worried but when I queried it with the various users under whose ID's the errors had been logged, they said nothing out of the ordinary had happened.
It's just dawned on me what's going on; when the user clicks on the button, there is a Microsoft Office security warning around opening a foreign file, along the lines of :
The dialog provides an OK / Cancel option. If the user clicks Cancel, this raises the error (even though technically nothing has really gone wrong - the user has opted not to open the file, rather than an actual failure to open the file at the described address)
I've no problem with the presence of the security warning (nor would I mind if it was bypassed altogether), but if it must remain, I would like to try to capture this scenario and not log any errors or prompt the user in a situation where they have opted to cancel out of the FollowHyperlink.
The only way I can think of is to put a condition in the error handler whereby if the error number is 16388, to just exit the routine (no prompt, no log). But I don't really like that as I'm guessing there could be situations where the user could choose OK but the hyperlink 'genuinely' couldn't be followed (for whatever reason), in which case I do want it prompted & logged. Or am I wrong? (would that result in a different error?)
I could also use ShellExecute instead of FollowHyperlink but I'd rather not incorporate API's and I'm not sure how it would handle .msg attachments either.
Any thoughts or suggestions?
Thanks
Al
I have a continuous subform of attachments which includes a command button for the user to open/view the attachment in question. It's fairly straightforward :
Code:
Private Sub comViewAttachment_Click()
On Error GoTo ErrorHandler
Application.FollowHyperlink Me.txtAttachmentPath.Value
Exit_comViewAttachment_Click:
Exit Sub
ErrorHandler:
Call LogError(Err.Number, _
Err.Description, _
"comViewAttachment_Click", _
Me.Name, _
"AttachmentID : " & Me.txtAttachmentID.Value & "; Path : " & Me.txtAttachmentPath.Value)
Resume Exit_comViewAttachment_Click
End Sub
However I noticed I was getting a number of errors logged, specifically :
Error 16388
The hyperlink cannot be followed to the destination
I got a bit worried but when I queried it with the various users under whose ID's the errors had been logged, they said nothing out of the ordinary had happened.
It's just dawned on me what's going on; when the user clicks on the button, there is a Microsoft Office security warning around opening a foreign file, along the lines of :
Opening XXX
Some files can contain viruses or otherwise be harmful to your computer.
It is important to be certain that this file is from a trustworthy source.
Would you like to open this file?
The dialog provides an OK / Cancel option. If the user clicks Cancel, this raises the error (even though technically nothing has really gone wrong - the user has opted not to open the file, rather than an actual failure to open the file at the described address)
I've no problem with the presence of the security warning (nor would I mind if it was bypassed altogether), but if it must remain, I would like to try to capture this scenario and not log any errors or prompt the user in a situation where they have opted to cancel out of the FollowHyperlink.
The only way I can think of is to put a condition in the error handler whereby if the error number is 16388, to just exit the routine (no prompt, no log). But I don't really like that as I'm guessing there could be situations where the user could choose OK but the hyperlink 'genuinely' couldn't be followed (for whatever reason), in which case I do want it prompted & logged. Or am I wrong? (would that result in a different error?)
I could also use ShellExecute instead of FollowHyperlink but I'd rather not incorporate API's and I'm not sure how it would handle .msg attachments either.
Any thoughts or suggestions?
Thanks
Al