R
Ray
Hi -
I'm using the following code to send an email when a user clicks on a
link ... the code works fine, EXCEPT that the Visual Basic Editor
opens as well!
Why would that happen? and more importantly ... how do I prevent it
from happening??
[Credit to Ron deBruin for the original code!]
In the ThisWorkbook module:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, _
ByVal Target As Hyperlink)
On Error Resume Next
Application.Run Target.TextToDisplay
If Err.Number = 0 Then Exit Sub ' This is leftover from the
original code
End Sub
In a standard code module:
Sub HNLR()
'Working in Office 2000-2007
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "Q: " & ActiveCell.Offset(0, -4).Value
.body = "[Please enter your question/comment here...]"
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Display '.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I'm using the following code to send an email when a user clicks on a
link ... the code works fine, EXCEPT that the Visual Basic Editor
opens as well!
Why would that happen? and more importantly ... how do I prevent it
from happening??
[Credit to Ron deBruin for the original code!]
In the ThisWorkbook module:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, _
ByVal Target As Hyperlink)
On Error Resume Next
Application.Run Target.TextToDisplay
If Err.Number = 0 Then Exit Sub ' This is leftover from the
original code
End Sub
In a standard code module:
Sub HNLR()
'Working in Office 2000-2007
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "Q: " & ActiveCell.Offset(0, -4).Value
.body = "[Please enter your question/comment here...]"
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Display '.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub