You can do this by subclassing the control and suppressing the WM_PASTE message which is sent to a control for performing a paste operation.
See the following code.
Place two command buttons and a text box on the form and insert the following code.
___
[tt]
Private Sub Form_Load()
Command1.Caption = "Enable paste"
Command2.Caption = "Disable paste"
End Sub
Private Sub Command1_Click()
EnablePaste Text1.hWnd
End Sub
Private Sub Command2_Click()
DisablePaste Text1.hWnd
End Sub[/tt]
___
Now place the following subclassing code in a module and test the program.
___
[tt]
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const GWL_WNDPROC = (-4)
Const WM_PASTE = &H302
Dim lppwp As Long 'Pointer to Previous Window Procedure
Private Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = WM_PASTE Then uMsg = 0
WindowProc = CallWindowProc(lppwp, hWnd, uMsg, wParam, lParam)
End Function
Sub EnablePaste(hWnd As Long)
If lppwp Then SetWindowLong hWnd, GWL_WNDPROC, lppwp
End Sub
Sub DisablePaste(hWnd As Long)
Dim Ret As Long
Ret = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
If lppwp = 0 Then lppwp = Ret
End Sub[/tt]