Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Right Click auto run macro

I would like to change the Right Mouse click on a basic excel worksheet so it
does not work as the conventional method of showing a list of available
processes, like copy, paste etc.... What I would like for it to do is to run
a specific macro automatically right off the Right Click. Basically then the
Right Click would have only one function which is to run that macro. Can
this be done.

Thank you,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Right Click auto run macro

Hi Steven,

Yes this can be done. In the VBA editor click on ThisWorkbook and add the
following code there. This will cause a macro to run whenever you right click
on any sheet in your workbook.
The code should be something like this:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
application.run "YourMacroName"
cancel = true
End Sub

If you want to attach to a specific sheet use the respective worksheet event.

"Steven" wrote:

I would like to change the Right Mouse click on a basic excel worksheet so it
does not work as the conventional method of showing a list of available
processes, like copy, paste etc.... What I would like for it to do is to run
a specific macro automatically right off the Right Click. Basically then the
Right Click would have only one function which is to run that macro. Can
this be done.

Thank you,

Steven

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Right Click auto run macro

Brotha,

Thank you for the response. I forgot to mention another item. I want this
to work regardless of which file I am in. If I have 5 files open then I want
the same response, regardless of the file I am in.

I have run the folling macro to adjust the Right Click control for example:

With Application.CommandBars("Cell").Controls
With .Add
.Caption = "Windows"
.OnAction = "'MacroFile'!ShowWorkbooks"
.Move Befo=2
End With
End With

Which works but this means when I RightClick then I have to select off the
popup list.... where what I want is to Right Click and automatically run the
macro.

So in summary, I want to remove all the Right Click items and replace it so
when the RightClick is pressed it will run the macro.

Thank you,

Steven

"Brotha Lee" wrote:

Hi Steven,

Yes this can be done. In the VBA editor click on ThisWorkbook and add the
following code there. This will cause a macro to run whenever you right click
on any sheet in your workbook.
The code should be something like this:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
application.run "YourMacroName"
cancel = true
End Sub

If you want to attach to a specific sheet use the respective worksheet event.

"Steven" wrote:

I would like to change the Right Mouse click on a basic excel worksheet so it
does not work as the conventional method of showing a list of available
processes, like copy, paste etc.... What I would like for it to do is to run
a specific macro automatically right off the Right Click. Basically then the
Right Click would have only one function which is to run that macro. Can
this be done.

Thank you,

Steven

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Right Click auto run macro

Steven,

These are two separate issues:
1) After right click a macro should run
If you end the right click event with Cancel = True no popup box will appear
so in my example beneath a macro will run directly after the right mouse is
clicked
2) The second item is you would like to control right click events all over
your open workbooks, so all will act the same. If you put the following code
in ThisWorkbook you can capture the events from the application. (You have to
save and re-open the file before the events will be captured)

Public WithEvents App As Application

Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As
Range, Cancel As Boolean)
application.run "YourMacro"
Cancel = True
End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub




"Steven" wrote:

Brotha,

Thank you for the response. I forgot to mention another item. I want this
to work regardless of which file I am in. If I have 5 files open then I want
the same response, regardless of the file I am in.

I have run the folling macro to adjust the Right Click control for example:

With Application.CommandBars("Cell").Controls
With .Add
.Caption = "Windows"
.OnAction = "'MacroFile'!ShowWorkbooks"
.Move Befo=2
End With
End With

Which works but this means when I RightClick then I have to select off the
popup list.... where what I want is to Right Click and automatically run the
macro.

So in summary, I want to remove all the Right Click items and replace it so
when the RightClick is pressed it will run the macro.

Thank you,

Steven

"Brotha Lee" wrote:

Hi Steven,

Yes this can be done. In the VBA editor click on ThisWorkbook and add the
following code there. This will cause a macro to run whenever you right click
on any sheet in your workbook.
The code should be something like this:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
application.run "YourMacroName"
cancel = true
End Sub

If you want to attach to a specific sheet use the respective worksheet event.

"Steven" wrote:

I would like to change the Right Mouse click on a basic excel worksheet so it
does not work as the conventional method of showing a list of available
processes, like copy, paste etc.... What I would like for it to do is to run
a specific macro automatically right off the Right Click. Basically then the
Right Click would have only one function which is to run that macro. Can
this be done.

Thank you,

Steven

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Right Click auto run macro

Brotha,

That is a major smokin hit. Thank you very much.

Steven

"Brotha Lee" wrote:

Steven,

These are two separate issues:
1) After right click a macro should run
If you end the right click event with Cancel = True no popup box will appear
so in my example beneath a macro will run directly after the right mouse is
clicked
2) The second item is you would like to control right click events all over
your open workbooks, so all will act the same. If you put the following code
in ThisWorkbook you can capture the events from the application. (You have to
save and re-open the file before the events will be captured)

Public WithEvents App As Application

Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As
Range, Cancel As Boolean)
application.run "YourMacro"
Cancel = True
End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub




"Steven" wrote:

Brotha,

Thank you for the response. I forgot to mention another item. I want this
to work regardless of which file I am in. If I have 5 files open then I want
the same response, regardless of the file I am in.

I have run the folling macro to adjust the Right Click control for example:

With Application.CommandBars("Cell").Controls
With .Add
.Caption = "Windows"
.OnAction = "'MacroFile'!ShowWorkbooks"
.Move Befo=2
End With
End With

Which works but this means when I RightClick then I have to select off the
popup list.... where what I want is to Right Click and automatically run the
macro.

So in summary, I want to remove all the Right Click items and replace it so
when the RightClick is pressed it will run the macro.

Thank you,

Steven

"Brotha Lee" wrote:

Hi Steven,

Yes this can be done. In the VBA editor click on ThisWorkbook and add the
following code there. This will cause a macro to run whenever you right click
on any sheet in your workbook.
The code should be something like this:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
application.run "YourMacroName"
cancel = true
End Sub

If you want to attach to a specific sheet use the respective worksheet event.

"Steven" wrote:

I would like to change the Right Mouse click on a basic excel worksheet so it
does not work as the conventional method of showing a list of available
processes, like copy, paste etc.... What I would like for it to do is to run
a specific macro automatically right off the Right Click. Basically then the
Right Click would have only one function which is to run that macro. Can
this be done.

Thank you,

Steven

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
Auto Right Click Steven Excel Programming 2 June 25th 08 04:27 PM
Auto populate w/click of a 'button' Shanen Excel Discussion (Misc queries) 6 April 28th 08 08:15 PM
Disable Auto save on Right Click Dvorakian Excel Discussion (Misc queries) 1 June 25th 06 12:34 PM
Auto Date/Time when click on cell MAGICofSeth Excel Programming 3 May 17th 04 02:36 AM
Auto-Click Save on Clipboard sowetoddid[_17_] Excel Programming 1 April 28th 04 01:15 AM


All times are GMT +1. The time now is 11:16 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"