Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel User Form -Text Frames - Right Mouse Click - Copy/Paste issue

Status
Not open for further replies.

hafod

Technical User
Mar 14, 2005
73
GB
Hi
Is it possible to enable the properties of the right mouse click in a user-form text box in Excel. This feature is enabled in VB(6) but does not appear to be available with VBA text box objects. This simple (Copy/Paste) feature will enable users to easily move text between Excel and a 3rd party target application running alongside Excel at run time, althought this is not the primary aim of the Excel VBA User Form which has many more text storage/checking features.

Hope you can shed some light on this for me!
Kind regards - Happy Easter.
 
I know this might not be the greatest solution to your problem but could you get your end users to use the key combinations (Ctrl+C,Ctrl+V) to do the copying/pasting? This is supported in the Textbox.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
hi Harleyquinn
Many thanks for response. Yes this works fine. Can this be automated as a macro, or can the Ctrl+C, Ctrl+V key press combinations be coded and added to say a command button?. If I can do this I will be more happy with the solution.
Best regards
Hafod
 
Hi,

Again, this might not be the best way to do this but you can do it with sendkeys.
Try something like (this is a brief example and can obviously be manipulated to suit your needs):
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 SendKeys "^{C}", True
[green]'Button = 2 signifies the right mouse button. Then if it is the right mouse button use sendkeys to send a Ctrl+C key combination for the copy. The syntax for paste is: SendKeys "+{INSERT}", True[/green]
End Sub
Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Another solution (not using sendkeys) that you could use with a button:
Code:
Private Sub CommandButton1_Click()
Dim a As String
a = TextBox1.SelText
Range("Z1").Value = a[green] 'you can set this to any cell the user won't see, you could even make the text white etc to hide it further[/green]
Range("Z1").Copy
End Sub
Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Hi Harleyquin,
Both solutions works a treat!! - more elegant. I WILL use the latter. Many thanks again.
Hafod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top