Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Context menu on userform

I have a userform with a load of text boxes for entering and editing data. I
want the ability to right click on a textbox in the form and choose cut, copy
or paste. When I right click on a textbox at the moment I get no menu at
all. CTRL X,C and V work but I want the right click enabled.

Is this possible?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Context menu on userform

Here is a technique posted by John Green last year

A short cut menu can be created as a popup commandbar. The menu can be
activated from the MouseUp event of the textbox.

You can create a popup menu using code like the following in a standard
module.

--------------------------------------------------------------------------
Sub MakePopUp()
'Remove any old instance of MyPopUp
On Error Resume Next
CommandBars("MyPopUp").Delete
On Error GoTo 0

With CommandBars.Add(Name:="MyPopUp", Position:=msoBarPopup)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "ShowDataForm"
.FaceId = 264
.Caption = "Data Form"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Sort"
.FaceId = 210
.Caption = "Sort Ascending"
End With
End With
End Sub

Sub ShowDataForm()
MsgBox "DataForm"
End Sub

Sub Sort()
MsgBox "Sort"
End Sub
----------------------------------------------------------------------

In your userform code module choose the Textbox from the top left dropdown
and the MouseUp event from the top right dropdown and insert something like
the following code:

----------------------------------------------------------------------------
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
Application.CommandBars("MyPopUp").ShowPopup
End If
End Sub
---------------------------------------------------------------------------


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Matthew" wrote in message
...
I have a userform with a load of text boxes for entering and editing data.

I
want the ability to right click on a textbox in the form and choose cut,

copy
or paste. When I right click on a textbox at the moment I get no menu at
all. CTRL X,C and V work but I want the right click enabled.

Is this possible?

TIA




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Context menu on userform

Thanks Bob,

I'm a bit of a newbie and thought that I would be able to turn on the
context menu somewhere and Excel would give me the default Cut, Copy and
Paste options. I am going to need help writing the code if indeed this is
what I need to do to get it to work.

TIA

Matthew

"Bob Phillips" wrote:

Here is a technique posted by John Green last year

A short cut menu can be created as a popup commandbar. The menu can be
activated from the MouseUp event of the textbox.

You can create a popup menu using code like the following in a standard
module.

--------------------------------------------------------------------------
Sub MakePopUp()
'Remove any old instance of MyPopUp
On Error Resume Next
CommandBars("MyPopUp").Delete
On Error GoTo 0

With CommandBars.Add(Name:="MyPopUp", Position:=msoBarPopup)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "ShowDataForm"
.FaceId = 264
.Caption = "Data Form"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Sort"
.FaceId = 210
.Caption = "Sort Ascending"
End With
End With
End Sub

Sub ShowDataForm()
MsgBox "DataForm"
End Sub

Sub Sort()
MsgBox "Sort"
End Sub
----------------------------------------------------------------------

In your userform code module choose the Textbox from the top left dropdown
and the MouseUp event from the top right dropdown and insert something like
the following code:

----------------------------------------------------------------------------
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
Application.CommandBars("MyPopUp").ShowPopup
End If
End Sub
---------------------------------------------------------------------------


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Matthew" wrote in message
...
I have a userform with a load of text boxes for entering and editing data.

I
want the ability to right click on a textbox in the form and choose cut,

copy
or paste. When I right click on a textbox at the moment I get no menu at
all. CTRL X,C and V work but I want the right click enabled.

Is this possible?

TIA





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Context menu on userform

if indeed this is
what I need to do to get it to work.



Sounds like you are still in doubt. So to clear it up:

There is no setting you can turn on to do what you want. You have to
program it.

--
Regards,
Tom Ogilvy

"Matthew" wrote in message
...
Thanks Bob,

I'm a bit of a newbie and thought that I would be able to turn on the
context menu somewhere and Excel would give me the default Cut, Copy and
Paste options. I am going to need help writing the code if indeed this is
what I need to do to get it to work.

TIA

Matthew

"Bob Phillips" wrote:

Here is a technique posted by John Green last year

A short cut menu can be created as a popup commandbar. The menu can be
activated from the MouseUp event of the textbox.

You can create a popup menu using code like the following in a standard
module.


--------------------------------------------------------------------------
Sub MakePopUp()
'Remove any old instance of MyPopUp
On Error Resume Next
CommandBars("MyPopUp").Delete
On Error GoTo 0

With CommandBars.Add(Name:="MyPopUp", Position:=msoBarPopup)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "ShowDataForm"
.FaceId = 264
.Caption = "Data Form"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Sort"
.FaceId = 210
.Caption = "Sort Ascending"
End With
End With
End Sub

Sub ShowDataForm()
MsgBox "DataForm"
End Sub

Sub Sort()
MsgBox "Sort"
End Sub
----------------------------------------------------------------------

In your userform code module choose the Textbox from the top left

dropdown
and the MouseUp event from the top right dropdown and insert something

like
the following code:


--------------------------------------------------------------------------

--
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
Application.CommandBars("MyPopUp").ShowPopup
End If
End Sub


--------------------------------------------------------------------------

-


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Matthew" wrote in message
...
I have a userform with a load of text boxes for entering and editing

data.
I
want the ability to right click on a textbox in the form and choose

cut,
copy
or paste. When I right click on a textbox at the moment I get no menu

at
all. CTRL X,C and V work but I want the right click enabled.

Is this possible?

TIA







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
Add find and replace to context menu wizardmalcolm Excel Discussion (Misc queries) 0 August 25th 09 12:16 PM
context menu formatting toolbar Robert New Users to Excel 2 July 30th 08 06:20 AM
Add items to context menu Fred Jacobowitz Excel Worksheet Functions 1 April 22nd 06 10:29 PM
context menu eric23 Excel Programming 3 May 9th 04 11:49 PM
Context sensitive menu Mark[_36_] Excel Programming 5 March 3rd 04 01:50 PM


All times are GMT +1. The time now is 11:48 PM.

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

About Us

"It's about Microsoft Excel"