Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RTF from excel into Rich text box 2

Status
Not open for further replies.

hamzajosh

Programmer
Sep 18, 2002
182
0
0
US
I want to store RTF data in an excel file into SQL and later retrieve it as RTF. I figured i can do this if i save the .textRTF object of a Rich Text Box in SQL. The problem i face is getting this data into the text box. From excel i can copy the data to clipboard and manually paste it into the Rich Text Box but when i try to use code to do it, i get plain text instead of RTF. I use the clipboard.gettext(format) function. I just can't get the right value for format for RTF. I keep on getting plain text. The exact thing i want to do is paste the RTF from clipboard to Rich Text box. If I can achieve this, all my problems will be solved. please help, any help would be highly appreciated.
 
You're using something like
"RichTextBox1.TextRTF = Clipboard.GetText(vbCFRTF)"
right, rather than
"RichTextBox1.TextRTF = Clipboard.GetText(vbCFText)"
...? gkrogers
 
Yes that is what i am doing
RichTextBox1.TextRTF = Clipboard.GetText(vbCFRTF)

should i be using the other one
 
No, that's right (at least it works fine for me here). In that case I can only guess that the formatting is being stripped out when you write it to or read it from the database.

What happens if you try pasting it into Word, using Ctrl-V? gkrogers
 
Manually, i can paste the RTF text in the rich text box also, it works fine that way, it's the code giving me the problem. I have an excel file with 50 columns and 10,000 rows, no way i can do that manually cell by cell. The same problem i have with word also. Word or excel do not give me textRTF object for selected cell or data like a rich text box does. Basically i need to convert this RTF text and get the textRTF string. Any other way than the way i am trying would be fine too
 
Any help here would be great, reopening the post

Learn everything but implement only what is needed.
 
wow that was awesome, man i really struggled with gettext method, this was easy. thanks a ton pal.

Learn everything but implement only what is needed.
 
More on this, when I copy an excel cell to clipboard and use the sendkeys to paste it in RTF box, it loses the font formatting, meaning i have some characters in symbol font, which become the default arial font. When i copy and paste from word, it works fine. I have RTF data that i need RTFtext for. Any idea why excel cell loses formatting and not word when pasted into an RTF text box. thanks.

Learn everything but implement only what is needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top