Hello,
I want to use Richtext.ocx from a vbs and i'm trying to do :

Set oRichtext = WScript.CreateObject("RICHTEXT.RichtextCtrl.1")
oRichtext.enabled = true
oRichtext.TextRtf = "toto"
oRichtext.Refresh
MsgBox "coucou"

But it doesn't work ! No error in compile, nor execution.

What is wrong?

Re: how to use Richtext.ocx from a vbs ? by mayayana

mayayana
Wed Apr 12 18:01:02 CDT 2006

There are several issues:

1) You need a license.

2) You need a GUI. It's a GUI control
that sits in a window. You can't just make
it pop up by itself.

3) The data types are incompatible. VBS is
dealing in variants, while the RTB methods
have more strict types. (Actually, your value
for TextRTF would not be valid anyway. The
TextRTF property is a RichText string. It requires
RichText formatting.)

Most Windows controls are not usable from script,
usually because of all of the reasons above. You
could probably do something similar in an IE window,
though.

> Hello,
> I want to use Richtext.ocx from a vbs and i'm trying to do :
>
> Set oRichtext = WScript.CreateObject("RICHTEXT.RichtextCtrl.1")
> oRichtext.enabled = true
> oRichtext.TextRtf = "toto"
> oRichtext.Refresh
> MsgBox "coucou"
>
> But it doesn't work ! No error in compile, nor execution.
>
> What is wrong?
>



Re: how to use Richtext.ocx from a vbs ? by mr_unreliable

mr_unreliable
Thu Apr 13 12:05:22 CDT 2006

Noel, you might try wordpad, which is nothing more than a
wrapper for the richedit control. It does have a progid
-- "Wordpad.Document.1" but afaik the only members are
"open", "print" and "printto", so you don't get access
to all the capabilities of the richedit control.

You might have better luck with msWord. It has an
automation interface (i.e., it's "scriptable"), and you
can colorize your text and background to your heart's
content.

Finally, as mayayana said, there are licensing "issues"
with richedit.

If you are looking for a wrapper for the richedit control
_for colorizing code_, then take a look at "Nathan's
CodeSense" (free).

(Saving the best for last), if you are looking for an actX
wrapper for microsoft's richedit control _that doesn't require
a license_, then take a look at Steve McMahon's (vbAccelerator)
richedit control, found here:

http://www.vbaccelerator.com/codelib/richedit/richedit.htm

Just to clarify things a bit, microsoft's richedit control
is the basis for vb's "richtext" control. That is, vb's
"richtext" control is a wrapper for richedit. Steve McMahon
also wrote up a wrapper for richedit, which he claims provides
more of the functionality of richedit than microsoft gives
you with the vb richtext control. You will have to judge that
claim for yourself, but in my opinion Steve's controls _are_
generally superior to microsoft's vb-version (i.e., in this
case the "RICHTX32.OCX" control).

Steve is offering all his controls for free, but than, you
still need a "form" to drop the control onto (i.e., serve as
a "host site" for the control).

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


noel wrote:
> Hello,
> I want to use Richtext.ocx from a vbs and i'm trying to do :
>
> Set oRichtext = WScript.CreateObject("RICHTEXT.RichtextCtrl.1")
> oRichtext.enabled = true
> oRichtext.TextRtf = "toto"
> oRichtext.Refresh
> MsgBox "coucou"
>
> But it doesn't work ! No error in compile, nor execution.
>
> What is wrong?
>