Convert text to RTF2

A

A.C.

hi,

i have a table with many record and i want to convert my memo (txt) in memo
rtf2.
I have also used the sub CmdRTF_Click post in newsgroup, but there is a
problem:
i see the text, but it isn't formatted. All the CRLF are exclused.

Is there anyone to help me?

Thank you
alessandro
 
A

A.C.

i have read in the newsgroup the post from "Disable right-click menu for
RTF2 " by Bogdan Zamfir
Where is the solutions?

Thank you.
alessandro

this is the code to convert text in rtf:

Sub CmdRTF()
On Error GoTo Err_CmdRTF_Click


Dim sRTFdata As String
Dim sHeader As String
Dim sText As String
Dim db As Database, rs As Recordset

Set db = CodeDb()
Set rs = db.OpenRecordset("Stampati", DB_OPEN_DYNASET)


sHeader =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1040{\fonttbl{\f0\fnil\fcharset0
Courier New;}}"
sHeader = sHeader & "{\colortbl
;\red0\green0\blue0;}\viewkind4\uc1\pard\cf1\f0\fs20"


With rs
' Move to first record
.MoveFirst


' Loop until all records are processed
' This example uses a field named "Comment"
' Note this is the name of the FIELD not the
' name of the TextBox control bound to this field
Do While Not .EOF
.Edit
sText = IIf(IsNull(.Fields("s_testo")), "", .Fields("s_testo"))
' See if field is empty
If Len(sText & vbNullString) = 0 Then
sRTFdata = sHeader & "}"
Else
sRTFdata = sHeader & sText & "\par }"
End If


' Save our RTF encoded string back to Comment field
.Fields("s_testo") = sRTFdata
.Update
' Move to next record
.MoveNext
Loop


End With


Exit_CmdRTF_Click:
Exit Sub


Err_CmdRTF_Click:
MsgBox Err.Description
Resume Exit_CmdRTF_Click


End Sub
 
S

Stephen Lebans

Opne the table with the Memo field that contains the RTF data. Copy and
paste one of the records here that fails to display properly.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
A

A.C.

this is the field after conversion:
Pistoia, 30 aprile 2002A richiesta dell'interessato si certifica che il
canedi nome LALLArazza YORK SHIRE TERRIERnato in Feb. 2001sesso Fmantello
nero focatodi proprieta' del Sig. ANTONIO VALLORSIresidente a PESARO in via
VIA PASTRENGO 8presenta alla grassella destra il seguente tatuaggio 2REA465.
TIMBRO E FIRMA



this is the field original:






Pistoia, 30 aprile 2002




A richiesta dell'interessato si certifica che il cane

di nome LALLA

razza YORK SHIRE TERRIER

nato in Feb. 2001

sesso F

mantello nero focato

di proprieta' del Sig. ANTONIO VALLORSI

residente a PESARO

in via VIA PASTRENGO 8

presenta alla grassella destra il seguente tatuaggio 2REA465.




TIMBRO E FIRMA

the original font is Courier New 10 pt.

this is the rtf field:

{\rtf1\ansi\ansicpg1252\deff0\deflang1040{\fonttbl{\f0\fnil\fcharset0
Courier New;}}{\colortbl
;\red0\green0\blue0;}\viewkind4\uc1\pard\cf1\f0\fs20




Pistoia, 30 aprile 2002




A richiesta dell'interessato si certifica che il cane

di nome LALLA

razza YORK SHIRE TERRIER

nato in Feb. 2001

sesso F

mantello nero focato

di proprieta' del Sig. ANTONIO VALLORSI

residente a PESARO

in via VIA PASTRENGO 8

presenta alla grassella destra il seguente tatuaggio 2REA465.




TIMBRO E FIRMA\par }
 
A

A.C.

this is the field after conversion:
Pistoia, 30 aprile 2002A richiesta dell'interessato si certifica che il
canedi nome LALLArazza YORK SHIRE TERRIERnato in Feb. 2001sesso Fmantello
nero focatodi proprieta' del Sig. ANTONIO VALLORSIresidente a PESARO in via
VIA PASTRENGO 8presenta alla grassella destra il seguente tatuaggio 2REA465.
TIMBRO E FIRMA



this is the field original:






Pistoia, 30 aprile 2002




A richiesta dell'interessato si certifica che il cane

di nome LALLA

razza YORK SHIRE TERRIER

nato in Feb. 2001

sesso F

mantello nero focato

di proprieta' del Sig. ANTONIO VALLORSI

residente a PESARO

in via VIA PASTRENGO 8

presenta alla grassella destra il seguente tatuaggio 2REA465.




TIMBRO E FIRMA

the original font is Courier New 10 pt.

this is the rtf field:

{\rtf1\ansi\ansicpg1252\deff0\deflang1040{\fonttbl{\f0\fnil\fcharset0
Courier New;}}{\colortbl
;\red0\green0\blue0;}\viewkind4\uc1\pard\cf1\f0\fs20




Pistoia, 30 aprile 2002




A richiesta dell'interessato si certifica che il cane

di nome LALLA

razza YORK SHIRE TERRIER

nato in Feb. 2001

sesso F

mantello nero focato

di proprieta' del Sig. ANTONIO VALLORSI

residente a PESARO

in via VIA PASTRENGO 8

presenta alla grassella destra il seguente tatuaggio 2REA465.




TIMBRO E FIRMA\par }
 
A

A.C.

this is the field after conversion:
Pistoia, 30 aprile 2002A richiesta dell'interessato si certifica che il
canedi nome LALLArazza YORK SHIRE TERRIERnato in Feb. 2001sesso Fmantello
nero focatodi proprieta' del Sig. ANTONIO VALLORSIresidente a PESARO in via
VIA PASTRENGO 8presenta alla grassella destra il seguente tatuaggio 2REA465.
TIMBRO E FIRMA



this is the field original:






Pistoia, 30 aprile 2002




A richiesta dell'interessato si certifica che il cane

di nome LALLA

razza YORK SHIRE TERRIER

nato in Feb. 2001

sesso F

mantello nero focato

di proprieta' del Sig. ANTONIO VALLORSI

residente a PESARO

in via VIA PASTRENGO 8

presenta alla grassella destra il seguente tatuaggio 2REA465.




TIMBRO E FIRMA

the original font is Courier New 10 pt.

this is the rtf field:

{\rtf1\ansi\ansicpg1252\deff0\deflang1040{\fonttbl{\f0\fnil\fcharset0
Courier New;}}{\colortbl
;\red0\green0\blue0;}\viewkind4\uc1\pard\cf1\f0\fs20




Pistoia, 30 aprile 2002




A richiesta dell'interessato si certifica che il cane

di nome LALLA

razza YORK SHIRE TERRIER

nato in Feb. 2001

sesso F

mantello nero focato

di proprieta' del Sig. ANTONIO VALLORSI

residente a PESARO

in via VIA PASTRENGO 8

presenta alla grassella destra il seguente tatuaggio 2REA465.




TIMBRO E FIRMA\par }
 
S

Stephen Lebans

Your RTF Header is not correct.

The RTF control can only display RTF encoded text. If you want to simply
display plain text then wrap your plain text within the required RTF
encoding.


Here's a previous post of mine on a related issue.
http://groups.google.ca/group/microsoft.public.access.forms/browse_fr...


From: Stephen Lebans - view profile
Date: Tues, Feb 14 2006 9:30 pm
Email: "Stephen Lebans"
<[email protected]>
Groups: microsoft.public.access.forms
Not yet ratedRating:
show options


Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse | Find messages by this author


Let me know how you make out.


Make sure your Form has:
A TextBox control named txtComment bound to the Comment field(just o you can
see the RTF encoding)
an RTF2 control bound to the Comment field
A CommandButton named cmdRTF


In your References, make sure the ref to DAO is higher in the list than ADO.


Place this code behind the Command Button.


Private Sub CmdRTF_Click()
On Error GoTo Err_CmdRTF_Click


Dim sRTFdata As String
Dim sHeader As String
Dim sText As String


sHeader =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0
Arial;}}"
sHeader = sHeader & "{\colortbl
;\red0\green0\blue0;}\viewkind4\uc1\pard\cf1\fs24"


' I could have shortened the code but I wanted you(and others I refer to
this posting) to see what is happening at every step.


With Me.RecordsetClone
' Move to first record
.MoveFirst


' Loop until all records are processed
' This example uses a field named "Comment"
' Note this is the name of the FIELD not the
' name of the TextBox control bound to this field
Do While Not .EOF
.Edit
sText = IIf(IsNull(.Fields("Comment")), "", .Fields("Comment"))
' See if field is empty
If Len(sText & vbNullString) = 0 Then
sRTFdata = sHeader & "}"
Else
sRTFdata = sHeader & sText & "\par }"
End If


' Save our RTF encoded string back to Comment field
.Fields("Comment") = sRTFdata
.Update
' Move to next record
.MoveNext
Loop


End With


Exit_CmdRTF_Click:
Exit Sub


Err_CmdRTF_Click:
MsgBox Err.Description
Resume Exit_CmdRTF_Click


End Sub



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
A

A.C.

i have made a program that translate text code in RTF and know the vbcr
code.

thank you
alessandro
 

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