Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

Copy-paste a file to a richtextbox?

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
gollem
Asked:
gollem
1 Solution
 
twalgraveCommented:
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
 
gollemAuthor Commented:
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
 
gollemAuthor Commented:
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
Technology Partners: 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!

 
twalgraveCommented:
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
 
gollemAuthor Commented:
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
 
twalgraveCommented:
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
 
gollemAuthor Commented:
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
 
GPrentice00Commented:
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
 
gollemAuthor Commented:
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
 
PashaModCommented:
Question closed and points refunded

PashaMod
CS Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now