cancel
Showing results for 
Search instead for 
Did you mean: 

what I have done wrong?I try to export the RTE to a MS-WORD file,but nothing in it.

Former Member
0 Kudos

hello sir/madam

    I try the following code,my purpose was I tried to export a Rich Text Datawindows to a MS-Word file,when the file have exported,there's nothing on it,I don't know what I have done wrong

//dw_exp is datawindow which is rich text datawindow

//rte_exp is rich text edit which I tried to export to a ms-word file

//dw_sub is the source that I trie to replace some text in dw_exp with.

//my

value = getfilesavename( "SAVEAS" ,path,name, "doc" , "Word files( *.doc),*.doc" )

if value=1 then

         dw_exp.reset()

         dw_exp.retrieve(ld_caseid)//I can't see the records appeared when it executed here.but actually there's a record in the table,just can't figure it out

         rte_exp.Clear()

         string ls_richtext

         string ls_prodname,ls_gjfzlx,ls_batch,ls_jx

         decimal ld_nxl,ld_ncl

         long ll_thenumber

         ls_richtext=dw_exp.CopyRTF()

         rte_exp.PasteRTF( ls_richtext)

         rte_exp.SetRedraw(False)

//the follwoing code I just tried to replace some text on the RTE control

         ll_type1count=0

          ll_type2count=2

      

                 for li_rowsub=1 to dw_sub.rowcount()

            ls_type=dw_sub.getitemstring(li_rowsub,"thetype")

             ls_prodname=dw_sub.getitemstring(li_rowsub,"prod_name")

             ls_gjfzlx=dw_sub.getitemstring(li_rowsub,"gjzlm")

             ls_batch=dw_sub.getitemstring(li_rowsub,"ph")

             ls_jx=dw_sub.getitemstring(li_rowsub,"jx")

              ld_nxl=dw_sub.getitemdecimal(li_rowsub,"nxsl")

              ld_ncl=dw_sub.getitemdecimal(li_rowsub,"ncl")

            if isnull(ls_type) then

                ll_type1count++

                ll_thenumber=ll_type1count

          

            else

                ll_type2count++  

                ll_thenumber=ll_type2count

            end if

         Integer  li_Loc

          li_Loc =rte_exp.Find("name"+string(ll_thenumber), True, &

                  true, &

                   true, True )

           if  li_Loc > 0 then

                rte_exp.ReplaceText(ls_prodname )

              

            end if

             li_Loc =rte_exp.Find("prodname"+string(ll_thenumber), True, &

                  true, &

                   true, True )

           if  li_Loc > 0 then

                rte_exp.ReplaceText( ls_gjfzlx )

              

            end if

          

             li_Loc =rte_exp.Find("batch"+string(ll_thenumber), True, &

                  true, &

                   true, True )

           if  li_Loc > 0 then

                rte_exp.ReplaceText( ls_batch )

              

            end if

          

             li_Loc =rte_exp.Find("jx"+string(ll_thenumber), True, &

                  true, &

                   true, True )

           if  li_Loc > 0 then

                rte_exp.ReplaceText( ls_jx )

              

            end if

          

             li_Loc =rte_exp.Find("sellanu"+string(ll_thenumber), True, &

                  true, &

                   true, True )

           if  li_Loc > 0 then

                rte_exp.ReplaceText(string(ld_nxl) )

              

            end if

                 li_Loc =rte_exp.Find("produceanu"+string(ll_thenumber), True, &

                  true, &

                   true, True )

           if  li_Loc > 0 then

                rte_exp.ReplaceText(string(ld_ncl) )

              

            end if

                       

                       

      

           next

          

          

       

  

       rte_exp.SaveDocument(path,FileTypeDoc! )

       

     end if

thanks

regards

Ken

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

please help,my problem hasn't  resolved

Former Member
0 Kudos

I've used RTF datawindows and RTF controls for awhile, and they're a mess.  If you can avoid them at all I would.  I have a to-do to move everything to OLE and Word, and skip the whole RTF datawindow altogether.  (More code, less messing around.)

When using a datawindow, always specify all parameters to the CopyRTF function.

     is_copytext = dw_2.CopyRTF( TRUE, DETAIL! )

When using a datastore, I have even more problems.  Here's what I have to do to successfully get the data out.

     ls_ret = lnds_form.Modify( "Datawindow.RichText.InputFieldNamesVisible=No" )

     ls_letter = lnds_form.CopyRTF( FALSE, DETAIL! )

Good luck buddy.

Former Member
0 Kudos

One other thing: That TRUE in the first example is because that code example implements a CUT for the client, who has already selected text.  If you want the whole band you need to use FALSE.

Former Member
0 Kudos

thanks Jeff,it works!!!thanks a lot

best regards

Ken

Former Member
0 Kudos

Hi Ken;

  FWIW: Make sure that you check all your method call return codes.

For example:

1) Retrieve ( )  .... Check # Rows

2) CopyRTF ()  ... Check the Length of the text returned

etc

Regards ... Chris

Former Member
0 Kudos

OK,thank you for reminding me,I'll try to debug it and find what I have done wrong,

best regards

Ken

Former Member
0 Kudos

Hi Chris

     I still have issue,although I'm very familar with Grid & free style Datawindow and I have used PB for 5 years,however, I'm not familar with rich text datawindow and rich text edit control at all.I have trouble that I have copy the document form rich text datawindow,but the data which produce by columns didn't on the RTE control,there is no data except the documnet content on the ms-word file.and I have googled this and watch the help file for almost a day,I didn't found the answer,I can't figure out what I have done wrong.please help

my code is following ,thanks!

     dw_exp.reset()

         dw_exp.retrieve(ld_caseid)

         rte_exp.Clear()

         string ls_prodadd

          datetime ld_begtime,ld_endtime

          string ls_taken,ls_yyyy

   

         ls_richtext=dw_exp.CopyRTF(false)

           ll_thecount=rte_exp.PasteRTF( ls_richtext,Detail!)

          if  ll_thecount<0 then

            messagebox("warnning","application terminated,because there are exception on pasting")

            return

        end if

rte_exp.SetRedraw(TRUE)
rte_exp.SaveDocument(path,FileTypeDoc! )

     messagebox("hello","export finish!")

Regards

Ken

Former Member
0 Kudos

FYI: The CopyRTF ( ) command only copies the "selected" text.

Have you tried placing a SelectText () or SelectTextAll () before the CopyRTF() command?

Former Member
0 Kudos

hello

     thank you for replying me,no,I didn't use SelectTextAll (),but the document content have copied to RTE,it just has not data  on the columns

regards

Ken

Former Member
0 Kudos

hello

     I just have tried to add the SelectTextAll (),it doesn't work,there still no data except the document content on the RTE control

best regards

Ken

Former Member
0 Kudos

BTW:  What version of PB are you using?

Former Member
0 Kudos

12.5

Former Member
0 Kudos

BTW: I have fix the issue which is there's nothing on the ms-word file,however,there's a issue that there's no data content on the file,it just only there's static text content on the file

best

Ken