944,129 Members | Top Members by Rank

Ad:
Sep 3rd, 2007
0

Convert Word document into a RichText Format document

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Sep 4th, 2007
0

Re: Convert Word document into a RichText Format document

Hi,

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

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim Oword As Object
  2. Dim Odoc As Object
  3.  
  4. Private Sub Command1_Click()
  5. Set Oword = CreateObject("Word.Application")
  6. Set Odoc = Oword.documents.open("C:\temp.doc")
  7. Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=wdFormatRTF
  8. Oword.quit
  9.  
  10. Me.RichTextBox1.FileName = "C:\x.rtf"
  11. End Sub
Reputation Points: 13
Solved Threads: 29
Junior Poster
kb.net is offline Offline
169 posts
since Aug 2007
Sep 8th, 2007
0

Re: Convert Word document into a RichText Format document

Thanks KB ,

But, now I can't make it work, the "wdFormatRTF" is a non recognized variable , 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
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Sep 9th, 2007
0

Re: Convert Word document into a RichText Format document

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

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim Oword As Object
  2. Dim Odoc As Object
  3.  
  4. Private Sub Command1_Click()
  5. Set Oword = CreateObject("Word.Application")
  6. Set Odoc = Oword.documents.open("C:\temp.doc")
  7. Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=6
  8. Oword.quit
  9. Me.RichTextBox1 = ""
  10. Me.RichTextBox1.FileName = "C:\x.rtf"
  11. End Sub
Reputation Points: 13
Solved Threads: 29
Junior Poster
kb.net is offline Offline
169 posts
since Aug 2007
Sep 10th, 2007
0

Re: Convert Word document into a RichText Format document

Thanks man!!,

That worked great!!, now I'm trying with other formats, I'll post how i'm doing with it...
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Jan 24th, 2009
0

Re: Convert Word document into a RichText Format document

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
The Neophyte is offline Offline
1 posts
since Jan 2009
Jan 24th, 2009
0

Re: Convert Word document into a RichText Format document

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: generating access report on click
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: help :)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC