简体   繁体   中英

paste richtextformat in word without using of the clipboard or creating new word file

Is there any way to insert richtextbox text that uses colors in word without using the clipboard or creating a new word file?

Word.Selection sel = wordApp.Selection;
sel.InsertAfter(richTextBox2.SelectedRtf);

This is inserts raw RTF code

Step 1: save the content of your richtextbox to a temporary .rtf file

Step 2: Collapse your Selection to the end or better yet: use a Range object instead of Selection

Step 3: Selection.InsertFile([pathtoyourtemprtf], Link:=False)

Step 4: You can now safely delete your temporary rtf file.

Will that do?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM