Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MAB MAB is offline
external usenet poster
 
Posts: 40
Default SheetBeforeRightClick stops firing if macro populates data

The SheetBeforeRightClick event I created works initially when I open the
workbook but if I (with a macro) clear all the data (except header row) then
repopulate with new data, SheetBeforeRightClick stops firing? Any ideas why?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default SheetBeforeRightClick stops firing if macro populates data

Something to look for would be that you set application.enableevents to false
and then don't turn it back on again. At that point no events will be firing
and your double click will not register. Other than that you need to post
some code so we can see what you are talking about...
--
HTH...

Jim Thomlinson


"MAB" wrote:

The SheetBeforeRightClick event I created works initially when I open the
workbook but if I (with a macro) clear all the data (except header row) then
repopulate with new data, SheetBeforeRightClick stops firing? Any ideas why?

  #3   Report Post  
Posted to microsoft.public.excel.programming
MAB MAB is offline
external usenet poster
 
Posts: 40
Default SheetBeforeRightClick stops firing if macro populates data

I am not setting application.enableevents to false.

'Class module ---------------------------------------------------------

Private WithEvents xlApp As Excel.Application

Private Sub Class_Initialize()
Set xlApp = Excel.Application
End Sub

'Doesn't seem to auto-execute
'Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
' MsgBox "xlApp_WorkbookOpen"
'End Sub

Private Sub xlApp_SheetBeforeRightClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)

MsgBox "xlApp_SheetBeforeRightClick " & Target.Address & " " &
Target.Hyperlinks.Count
'Add or remove Hyperlink menu items based on whether or not Hyperlink(s)
are selected

Dim oCtrl As CommandBarControl
Dim oBtn As CommandBarControl
Dim bMenusExist As Boolean
Dim bHyperlinksExist As Boolean

For Each oCtrl In Application.CommandBars("Cell").Controls
If oCtrl.Caption = "Copy Hyperlinked Docs To..." Then
bMenusExist = True
Exit For
End If
Next

bHyperlinksExist = Target.Hyperlinks.Count 0

If bHyperlinksExist And Not bMenusExist Then
Set oCtrl =
Application.CommandBars("Cell").Controls.Add(Type: =msoControlButton, _
Temporary:=True)
oCtrl.Caption = "Copy Hyperlinked Docs To..."
oCtrl.OnAction = "CopyHyperlinkedDocsTo"

Set oCtrl =
Application.CommandBars("Cell").Controls.Add(Type: =msoControlButton, _
Temporary:=True)
oCtrl.Caption = "Zip && Email Hyperlinked Docs..."
oCtrl.OnAction = "ZipAndEmailHyperlinkedDocs"

' Set oCtrl =
Application.CommandBars("Cell").Controls.Add(Type: =msoControlButton, _
' Temporary:=True)
' oCtrl.Caption = "Print Hyperlinked Docs..."
' oCtrl.OnAction = "PrintHyperlinkedDocs"
ElseIf Not bHyperlinksExist Then
For Each oCtrl In Application.CommandBars("Cell").Controls
If oCtrl.Caption = "Copy Hyperlinked Docs To..." Then
oCtrl.Delete
ElseIf oCtrl.Caption = "Zip && Email Hyperlinked Docs..." Then
oCtrl.Delete
ElseIf oCtrl.Caption = "Print Hyperlinked Docs..." Then
oCtrl.Delete
End If
Next
End If
End Sub

'Regular module --------------------------------------------------------------

Public moXLEvents As clsXLEvents



'ThisWorkbook -----------------------------------------------------------

Private Sub Workbook_Open()
Dim oWorksheet As Worksheet

Set moXLEvents = New clsXLEvents
Set oWorksheet = ThisWorkbook.ActiveSheet
If oWorksheet.Range("a2").Value = "" Then
ListNewerFiles.Show vbModal
End If
End Sub


"Jim Thomlinson" wrote:

Something to look for would be that you set application.enableevents to false
and then don't turn it back on again. At that point no events will be firing
and your double click will not register. Other than that you need to post
some code so we can see what you are talking about...
--
HTH...

Jim Thomlinson


"MAB" wrote:

The SheetBeforeRightClick event I created works initially when I open the
workbook but if I (with a macro) clear all the data (except header row) then
repopulate with new data, SheetBeforeRightClick stops firing? Any ideas why?

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
drop down list populates data in another cell Amanda H Excel Discussion (Misc queries) 4 December 31st 08 07:28 PM
Type data in one cell - and it automatically populates another cel Tom Excel Worksheet Functions 5 March 18th 07 04:21 AM
Macro not firing off Hiran de Silva[_2_] Excel Programming 3 March 12th 06 07:25 PM
Trap SheetBeforeRightClick event from another workbook mp112849 Excel Programming 2 June 15th 05 10:32 AM
Event sometimes stops firing? HotRod Excel Programming 7 May 5th 05 12:20 AM


All times are GMT +1. The time now is 09:05 PM.

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"