Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Control Sequence from Userform Control

In a userform textbox I can use ctrl+v to paste a previously copied text
item. How can I intiate this sequence or indeed any other keyboard control
or escape sequence from a control button?
TIA

--
Cheers
Nigel




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Control Sequence from Userform Control

Hi All,
Discovered a method to paste as follows, however the event is triggered
twice so I paste the data twice, so my questions are

1. Why does the mousedown event run twice ?
2. If this is normal how do I handle this double event?

I need to be able to paste the contents of the clipboard into TextBox1 just
once, I could either apply extra code to prevent the double copying or clear
the clipboard after the first copy occurs - which is the better option and
how do I achieve this?

Private Sub TextBox1_MouseDown(ByVal Button As Integer _
, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If Button = 2 Then
SendKeys "^v"
End Sub

--
Cheers
Nigel



"Nigel" wrote in message
...
In a userform textbox I can use ctrl+v to paste a previously copied text
item. How can I intiate this sequence or indeed any other keyboard

control
or escape sequence from a control button?
TIA

--
Cheers
Nigel






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Control Sequence from Userform Control

Nigel,

Double events usually happen because the action within the event causes
exactly the same event that was initially trapped, firing the event a second
time before the first finishes. With worksheet and workbook events, you turn
EnableEvents off, but this doesn't work for forms, so you need to do it
yourself.

An example for you would be

Dim fReEntry As Boolean

Private Sub TextBox1_MouseDown(ByVal Button As Integer _
, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If Not fReEntry Then
fReEntry = True
If Button = 2 Then SendKeys "^v"
fReEntry = False
End If
End Sub

--

HTH

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


"Nigel" wrote in message
...
Hi All,
Discovered a method to paste as follows, however the event is triggered
twice so I paste the data twice, so my questions are

1. Why does the mousedown event run twice ?
2. If this is normal how do I handle this double event?

I need to be able to paste the contents of the clipboard into TextBox1

just
once, I could either apply extra code to prevent the double copying or

clear
the clipboard after the first copy occurs - which is the better option and
how do I achieve this?

Private Sub TextBox1_MouseDown(ByVal Button As Integer _
, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If Button = 2 Then
SendKeys "^v"
End Sub

--
Cheers
Nigel



"Nigel" wrote in message
...
In a userform textbox I can use ctrl+v to paste a previously copied text
item. How can I intiate this sequence or indeed any other keyboard

control
or escape sequence from a control button?
TIA

--
Cheers
Nigel








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Control Sequence from Userform Control

Hi Bob
Thanks for the reply. In fact I tried a similar approach to your proposal
but as with yours the setting of the boolean to False on exit allows the
retrigger to occur again! It appears that the whole event re-runs - if I
leave the boolean as false then I cannot reapply the paste until I unload
and reload the userform.

I could use another form event to set the boolean to False, but I just seem
to be building up layers of complexity that I do not feel happy about. It
has just got to be simpler than this - hasn't it??

---
Cheers
Nigel



"Bob Phillips" wrote in message
...
Nigel,

Double events usually happen because the action within the event causes
exactly the same event that was initially trapped, firing the event a

second
time before the first finishes. With worksheet and workbook events, you

turn
EnableEvents off, but this doesn't work for forms, so you need to do it
yourself.

An example for you would be

Dim fReEntry As Boolean

Private Sub TextBox1_MouseDown(ByVal Button As Integer _
, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If Not fReEntry Then
fReEntry = True
If Button = 2 Then SendKeys "^v"
fReEntry = False
End If
End Sub

--

HTH

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


"Nigel" wrote in message
...
Hi All,
Discovered a method to paste as follows, however the event is triggered
twice so I paste the data twice, so my questions are

1. Why does the mousedown event run twice ?
2. If this is normal how do I handle this double event?

I need to be able to paste the contents of the clipboard into TextBox1

just
once, I could either apply extra code to prevent the double copying or

clear
the clipboard after the first copy occurs - which is the better option

and
how do I achieve this?

Private Sub TextBox1_MouseDown(ByVal Button As Integer _
, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If Button = 2 Then
SendKeys "^v"
End Sub

--
Cheers
Nigel



"Nigel" wrote in message
...
In a userform textbox I can use ctrl+v to paste a previously copied

text
item. How can I intiate this sequence or indeed any other keyboard

control
or escape sequence from a control button?
TIA

--
Cheers
Nigel










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
How can we control the sequence in which the cursor moves in a for Mandigos Excel Discussion (Misc queries) 8 January 28th 08 05:40 PM
Userform control ZMore Excel Programming 1 March 5th 04 11:34 PM
Userform control Phillips Excel Programming 1 November 20th 03 07:33 PM
UserForm Control John Wilson Excel Programming 0 July 16th 03 06:53 PM
UserForm Control Richard Choate Excel Programming 0 July 16th 03 06:50 PM


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