Extract text as RTF without using the clipboard

C

Christoph Hilmes

Hi NG,

i have an application using vb and word. I control word from within my
vb-application using vba. At one point i extract the text of a document in
rtf format (with all the rtf-commands) and put it into a string-variable.
Then i replace parts of the text using a string-search-and-replace-
algorithm. Afterwards i paste the text back into the word-document so that
the formatting is not lost. To achieve that i use the windows-clipboard.

To get the text out of the document:

Select_Text pos_beginn, pos_end
Clipboard.Clear
wordobj.Selection.Cut
text = Clipboard.GetText(vbCFRTF)

To paste it back into the document

Clipboard.Clear
Clipboard.SetText "{" & text_ein & "}", vbCFRTF
Select_Text pos_beginn, pos_end
wordobj.Selection.Range.Paste

That works pretty well on most systems. But with certain configurations
(most of all terminal-server-emulations) i got problems using the
clipboard. Therefore i search for another solution for my problem without
using the clipboard.

Can anybody help me here?

Thanks in advance.

Christoph
VB 6
Word 2000
 
J

Jonathan West

The only two ways I'm aware of for extracting and manipulating an RTF
snippet from a document are as follows

1. The clipboard.

2. Moving/copying the text to a fresh document (using the FormattedText
method), and saving the document as an RTF file, and manipulating the RTF
from there.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top