?
Solved

Copy-paste a file to a richtextbox?

Posted on 2003-02-19
10
Medium Priority
?
449 Views
Last Modified: 2013-12-25
I want to programmatically copy/add a file(s) to a richtextbox.  The file is not a picture but a word-doc, excel.doc, txt-file,...

Not the name of the file, and not the contents of the file, but as an attachment.  Just as if I right-clicked a file in Windows Explorer, clicked Copy, then pasted it into the richtextbox.
0
Comment
Question by:gollem
[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
10 Comments
 
LVL 16

Expert Comment

by:twalgrave
ID: 7985189
You need to use the OLE objects the RichTextBox supports for this.  

see here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rtfbox98/html/vbobjrichedit.asp
0
 

Author Comment

by:gollem
ID: 7987003
Hello, sorry for my late reply. (no email response)

Could you please give me a little example code.  For example I want to add automatically the file(s) path\test.doc, or/and path\test.xls to the richtextbox.

I 've tried different ways but none worked.

Thank you

0
 

Author Comment

by:gollem
ID: 7987097
By the way, I've checked your info about the OLEObjects.

I'v tried it, but I get the contents of the file, I would like to have the file as a shortcut(a file) in the richtextbox.  Just like in Outlook when you insert a file or when you copy in the explorer a file and then copy it into the richtextbox.

Maybe I'm doing something wrong?

Thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 16

Expert Comment

by:twalgrave
ID: 7988805
Natively RichTextBoxes do not support hyperlinks like you are talking about.  You can however, look here:

http://www.csdn.net/Develop/article/12%5C12774.shtm
0
 

Author Comment

by:gollem
ID: 7992128
Hello again,

I've checked the link information but I'can't download the project example. (so for the moment not helpful)

I've also tried the richtextbox.oleobjects.add method again.  After using the displaytype I got a nice result but the problem is that I can't add more documents, files.

The last approch I wanted to ask is copying the file to the clipboard and then paste it into a richtextbox.  I 've already found an example on this site but it's for VB.net, here's the code(copy file to clipboard):

Dim DataObject As New DataObject()
Dim file(0) As String
file(0) = "C:\Test.txt"
DataObject.SetData(DataFormats.FileDrop, file)
Clipboard.SetDataObject(DataObject)

Can you look at it please, maybe you can easy translate it because it doesn't work in a normal VB6 project. (The pasting can I do with an API)

By the way if you want more points, let me know.

0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7999814
I don't know why you cannot download from the last link provided.

Personally I don't think you're going to want to go the route you are looking at at the moment.  However, if you do, you will want to check out the following:
http://home.online.no/~rkaste/vb/vbhowto/clipbh.htm

0
 

Author Comment

by:gollem
ID: 8006697
I've checked the link, I know how to copy a picture(bmp-file), but I didn't find anything how to copy a none picture file(*.xls,*.doc,...) to the clipboard. Is this even possible? If not, I will have to use another solution.  
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9117827
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept twalgrave's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
 

Author Comment

by:gollem
ID: 9120080
Hello,

I understand that this question has to been cleaned up.  Do I have to accept the answer of twalgrave?  My question is still not answered correctly.

I have no problem that you delete my question.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 9170281
Question closed and points refunded

PashaMod
CS Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 Month14 days, 10 hours left to enroll

771 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