Solved

Cplipboard Copy and Paste

Posted on 2004-08-10
9
698 Views
Last Modified: 2008-02-01
Hi everyone, I've got a main form with an rtfBox and I'm trying to use functions copy and paste. Here's the deal, I have a menu with copy as CTR+C and Paste as CRT+V just like windows. However if I tried to paste RTF code to notepad nothing would show! So I added as follows:

    Clipboard.Clear
    Clipboard.SetText rtfBox.SelRTF, vbCFRTF
    Clipboard.SetText rtfBox.SelText

I'm able to paste to winword and to notepad. However, if I try to past on my own box with the menu paste:     rtfReferences.SelText = Clipboard.GetText  I get the text with no format. and If I press CRT+V that should evoke the same menu it pastes both rtf and normal text and i get the text twice. Can you help me make both functions like normal word processors?

Thank you very much!
0
Comment
Question by:igfp
9 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 11761600

Have you tried using GetData:
Clipboard.GetData (avbCFRTF)  'to read the RTF
Clipboard.GetData (avbCFText)  'to read the text

Cheers
0
 

Author Comment

by:igfp
ID: 11761654
no, I tried it now, it says: invalid clipboard format, however it keep having the same problem it writes the CTR+V of windows correctly and then it aborts with that message.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 300 total points
ID: 11761672
May be this


Private Sub rtfText_KeyDown(KeyCode As Integer, Shift As Integer)
   
    On Error Resume Next
    If Shift = 2 Then
        If KeyCode = 67 Then
            Clipboard.Clear
            Clipboard.SetText rtfBox.SelRTF, vbCFRTF
            Clipboard.SetText rtfBox.SelText
            KeyCode = 0
        ElseIf KeyCode = 86 Then
            SendKeys "^V"
            DoEvents
            KeyCode = 0
        End If
    End If
End Sub
0
 

Author Comment

by:igfp
ID: 11761705
shouldn't this work:

Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub

like this it still exits! and also with query unload... I don't get it!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Expert Comment

by:SRigney
ID: 11761735
igfp, I think your last post is in the wrong window.


The reason the rich text box pastes twice is that the rich textbox already implements it's own copy and paste with CTRL+V and CTRL+C.  You don't have to do anything to implement them.

0
 

Author Comment

by:igfp
ID: 11762087
So how do I evoke them on a menu like every window application? I'll check EDDYKT code in a few hours.
0
 
LVL 15

Expert Comment

by:SRigney
ID: 11763232
Because it is already implemented you can put the shortcuts on your menu to inform the user that it is available, but you don't have to handle the events.  They will already be handled for you.
0
 

Author Comment

by:igfp
ID: 11767894
Srigney you are right, after having deleted my subs It went exactly as I wanted, however, how do I put the shortcuts on the menu? how do I evoke this on my subs? So that the user may click on the menu instead of using the CTR+C for instance. Like all windows apps?
0
 
LVL 15

Expert Comment

by:SRigney
ID: 11777902
Good answer EDDYKT.  Sorry I wasn't able to get back to you very quickly igfp.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now