0

Greetings folks,

I need to load a word document file into a RichTextBox component, It can't be done directly, so, I need first, convert it to a RichText Format File and then load it to the component. Any Ideas?

Thanks

Omar

4
Contributors
6
Replies
11
Views
9 Years
Discussion Span
Last Post by Comatose
0

Hi,

Try this, I haven't been able to test it:

Dim Oword As Object
Dim Odoc As Object

Private Sub Command1_Click()
  Set Oword = CreateObject("Word.Application")
  Set Odoc = Oword.documents.open("C:\temp.doc")
  Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=wdFormatRTF
  Oword.quit

  Me.RichTextBox1.FileName = "C:\x.rtf"
End Sub
0

Thanks KB ,

But, now I can't make it work, the "wdFormatRTF" is a non recognized variable :S, I tried to look for other options, but I can't find any related (and relevant) info about those options on the "Word.Application" object, maybe you can show me how can I accomplish this. Thanks

0

Hi,
Just replace the wdFormatRTF with number 6 (this code is for VB6, if you are using different IDE please advise).

Dim Oword As Object
Dim Odoc As Object

Private Sub Command1_Click()
  Set Oword = CreateObject("Word.Application")
  Set Odoc = Oword.documents.open("C:\temp.doc")
  Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=6
  Oword.quit
Me.RichTextBox1 = ""
  Me.RichTextBox1.FileName = "C:\x.rtf"
End Sub
0

Thanks man!!,

That worked great!!, now I'm trying with other formats, I'll post how i'm doing with it...

0

ok i found this thread through google and im quite a novice at scripting but where exactly would i incert that bit of code you posted in my MS word documents code?

0

First, it's strongly frowned upon to post to threads that are more than three months old. Even if you have a question regarding an old thread, then you would start a new thread, and post a link to the old thread with your question. This will help to ensure that you get a warm and helpful welcome instead of the inevitable flaming that is sure to follow posting to old threads.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.