Inserting contents of Word document into a richtextbox control

T

Tammy

I'm trying to create a customised file open dialog box using a rich
text box to preview the selected document. I've tried the loadfile
method but I'd need to save the file as an RTF first which isn't
feasible. I've tried using the input function but get the "input past
end of file" error. I've searched Google groups and have tried the
advice there ... mainly changing
input to binary which loads the form but the richtextbox is filled
with rubbish characters. I've used the strconv function and this
didn't help. I've also tried opening the document and setting the
richtextbox text as the activedocument contents but this is too clumsy
for what I'm after.

I've tried OLE containers in VB which worked but couldn't access them
in Word. After searching in groups I realised that Word doesn't use
them. I've also tried the web browser but it keeps crashing.

I even tried creating my own ActiveX control in VB but don't have the
experience to do that. Also tried searching on WordPad to try and
work out how it goes it to no avail.

Has anybody populated a Richtextbox with a Word document without Word
opening up first?

Thanks
Tammy
 
P

Peter Hewett

Hi Tammy

You're out of luck I'm afraid. As you've discovered the RTF control expects an RTF
document. The problem is, is that you are expecting a control to load a Word binary
format file (a Word document) and then display it as Word would. Obviously to do this you
need something (aka Word) to load, format and display this binary data.

If you think about it this makes perfect (albeit in your case unpalatable) sense.

HTH + Cheers - Peter


(e-mail address removed) (Tammy), said:
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Tammy > écrivait :
In this message, < Tammy > wrote:

|| I'm trying to create a customised file open dialog box using a rich
|| text box to preview the selected document. I've tried the loadfile
|| method but I'd need to save the file as an RTF first which isn't
|| feasible. I've tried using the input function but get the "input past
|| end of file" error. I've searched Google groups and have tried the
|| advice there ... mainly changing
|| input to binary which loads the form but the richtextbox is filled
|| with rubbish characters. I've used the strconv function and this
|| didn't help. I've also tried opening the document and setting the
|| richtextbox text as the activedocument contents but this is too clumsy
|| for what I'm after.
||
|| I've tried OLE containers in VB which worked but couldn't access them
|| in Word. After searching in groups I realised that Word doesn't use
|| them. I've also tried the web browser but it keeps crashing.
||
|| I even tried creating my own ActiveX control in VB but don't have the
|| experience to do that. Also tried searching on WordPad to try and
|| work out how it goes it to no avail.
||
|| Has anybody populated a Richtextbox with a Word document without Word
|| opening up first?
||

Are you trying to do this from VBA? If so, what Word version?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

Tammy

Hi Jean-Guy,

I am trying to do this from VBA - the versions of Word I'm using are
Word XP (mainly but I also need it to work in Word 2003. I've
downloaded the evaluation copy of the tx text control as that's meant
to do what I'm after but couldn't get it to run. I'd prefer to work
it out anyway if possible.

Thanks
Tammy
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Tammy > écrivait :
In this message, < Tammy > wrote:

|| Hi Jean-Guy,
||
|| I am trying to do this from VBA - the versions of Word I'm using are
|| Word XP (mainly but I also need it to work in Word 2003. I've
|| downloaded the evaluation copy of the tx text control as that's meant
|| to do what I'm after but couldn't get it to run. I'd prefer to work
|| it out anyway if possible.
||

In Word 2002 you can open a document in an invisible state (Documents.Open
FIleName, Visible:=False).
So, I think you could open the Word doc, save it as RTF, close it, load the
RTF version in the control, then delete the RTF when you are done. It would
be a bit slow, but it would be invisible to the user.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

mbaird

Be careful about using the rich text control with Office 2003. I could never get it to work because of new security enhancements with Outlook.

Mark Baird
 
T

Tammy

That sounds like a good option. I might set it up so they need to
click on a preview button to preview rather than have the document
preview automatically as they scroll down the list.

Thanks heaps for your help!
 
T

Tammy

Thanks Mark - I might test that before I spend too much time getting
it to work in XP.
 
T

Tammy

Hi Mark,

Did have problems with the richtextbox control in Word 2003 but after
searching the groups re the problem came up with this which I
implemented and did fix the problem. Hope it can help you as well.

*******************************************************************************

After carefully reviewing your issue, we have determined that your
issue is
working
as designed per the new enhanced security features in Office 2003. We
do
have some
workarounds that you can use.

It actually Internet Explorer that is reporting these controls cannot
be
trusted. To get the option
to view the controls, you can implement the following registry key
change.

Note: Exercise caution when changing the Windows registry. Changing
the
wrong registry entry or making an incorrect
entry for a setting can introduce an error that prevents Windows
from
starting or working properly. It is always suggested that
you backup your registry before making any changes.

Registry Key :
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\ActiveX
Compatibility\{3B7C8860-D78F-101B-B9B5-04021C009402}

Change the "Compatibility Flags" DWORD value to 0 (0x400 is kill bit).
Now
you'll
get prompted to trust loading the control and it will run.

*******************************************************************************

Tammy
 

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