Solved

Cplipboard Copy and Paste

Posted on 2004-08-10
9
704 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Suggested Courses
Course of the Month6 days, 1 hour left to enroll

627 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