Solved

Cplipboard Copy and Paste

Posted on 2004-08-10
9
701 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 143

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 141
Sending a email via excel using vba 6 109
vb6 connector to mongodb 2 140
Access2016 ignore hyphen in data entry or searches 5 45
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 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