Solved

Cplipboard Copy and Paste

Posted on 2004-08-10
9
697 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now