Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default VBE opens automatically -- why??

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 = "
.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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBE opens automatically -- why??

It may be the application.run

For example, I have a workbook that I always want the VBE editor to open
when the workbook is opened. So have have in the workbook code area the
following:

Private Sub Workbook_Open()
Application.Goto "demo"
End Sub

Where "demo" is the name of a sub in a standard module.
--
Gary''s Student - gsnu200907


"Ray" wrote:

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 = "
.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

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default VBE opens automatically -- why??

Gary -

Makes sense ... but how do I fix it? I tried changing Application.Run
to Application.GoTo -- same result ...

Basically, when the user clicks on a hyperlink (which is someone's
name), a macro (named the same way) should be fired ...

the code above works great, EXCEPT that the VBE opens also, which will
confuse my users ...

TIA,
ray

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default VBE opens automatically -- why??

I don't get the VBE opening.
Are you getting any kind of error messages? rem out the ON ERROR RESUME
NEXT line as this is hiding issues from you

"Ray" wrote:

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 = "
.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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default VBE opens automatically -- why??

I don't get the VBE opening.

Same here

No problem in O 2003 and also not in O 2010

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Patrick Molloy" wrote in message
...
I don't get the VBE opening.
Are you getting any kind of error messages? rem out the ON ERROR RESUME
NEXT line as this is hiding issues from you

"Ray" wrote:

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 = "
.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




  #6   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default VBE opens automatically -- why??

Interesting ... is there a VBE setting that would cause this issue? I
just tried it again, same result ... VBA springs open, as does the new
Outlook mail.

Thanks for looking into it!

ray
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA opens up automatically FARAZ QURESHI Excel Discussion (Misc queries) 3 June 4th 09 09:28 AM
Spreadsheet automatically opens as 'read-only' cambo Excel Discussion (Misc queries) 5 April 16th 08 11:18 AM
One particular worksheet always automatically opens when opening E loren Excel Discussion (Misc queries) 0 March 9th 08 10:40 PM
Excel automatically opens files FileCrazy Excel Discussion (Misc queries) 7 December 12th 06 04:58 PM
File automatically opens Brad Excel Discussion (Misc queries) 1 January 6th 06 05:00 PM


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"