Pas d'inquiétude, avec PBAdonf, c'est dans la poche ! ^^

Le forum (ô combien francophone) des utilisateurs de Powerbuilder.

Recherche rapide

Annonce

Certaines rubriques, dont des cours, sont uniquement visibles par les membres du forum ^^.
Dans la rubrique Liens & Références, vous avez accès à un sommaire de téléchargement, profitez-en !
Il existe maintenant un nouveau TOPIC "Votre CV en Ligne" accessible uniquement par demande.

#1 12-05-2010 07:54:05

champagne  
Membre Geek
Lieu: WAVRIN
Date d'inscription: 12-05-2010
Messages: 25
Pépites: 3
Banque: 0

Insertion DW dans un document word

Bonjour a tous les mordus de PB

je fais du publipostage....

j'aimerais inserer dans ma lettre une datawindow 6 colonnes et x lignes suivant le clients...

vous avez des astuces...

merci

Hors ligne

 

#2 12-05-2010 08:18:31

erasorz  
Admin
Lieu: Babylone
Date d'inscription: 23-11-2006
Messages: 5121
Pépites: 97,197
Banque: 2,147,483,647

Re: Insertion DW dans un document word


N'envoyez jamais un humain faire le travail d'un programme.

Hors ligne

 

#3 12-05-2010 09:06:00

champagne  
Membre Geek
Lieu: WAVRIN
Date d'inscription: 12-05-2010
Messages: 25
Pépites: 3
Banque: 0

Re: Insertion DW dans un document word

Merci pour la reponse rapide

je voudrais inserer ma datawindow à l'emplacement d'une balise dans word....
j'avais parcouru les pics mais je n'avais pas la bonne solution...

Le code suivant fonctionne tres bien .. il me reste à inserer ma datawindow..

merci pour les reponses

Code: pb

boolean lb_set_remote_ok, lb_execremote_fileopen
integer li_value, li_msgbox, li_fileopen, li_rc, li_run, li_ctr
long    ll_rowcount, ll_len, ll_ddehandleword, ll_ddehandledoc, i,ll_compteur,numcols ,numrows 
string  ls_sd_id, ls_fname, ls_lname, ls_street, ls_street1, ls_street2, ls_city, ls_state, ls_zip, &
        ls_word_exe_arr[], ls_word_exe, ls_named, ls_docname 

// determine what Word exe to call 4/20/2006 dlmuench
ls_word_exe_arr[1] =  "C:\Program Files\Microsoft Office\Office10\WINWORD.EXE"
ls_word_exe_arr[2] =  "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE"

FOR li_ctr = 1 TO UpperBound(ls_word_exe_arr)
   IF FileExists(ls_word_exe_arr[li_ctr] ) THEN
      ls_word_exe = ls_word_exe_arr[li_ctr]
      EXIT
   END IF
NEXT

lb_set_remote_ok = TRUE
lb_execremote_fileopen = FALSE

li_value = GetFileOpenName("Select Seed Letter Document to Print", + ls_docname, ls_named, "DOC", + "Doc Files (*.DOC),*.DOC" )
IF li_value > 0 THEN //user opens a file

   //try to open a channel to Word
   ll_ddehandleword = OpenChannel("WinWord", "System" )
   IF ll_ddehandleword < 0 THEN //if open channel fails, run the Word application
      li_run = Run(ls_word_exe, Minimized! )
      IF li_run < 0 THEN
         RETURN -1
      END IF
   END IF

   IF li_value = 1 THEN
      li_msgbox = MessageBox("Attention", &
                  "The file that you have chosen is" + " " + ls_docname + " " + &
                  ".~nDo you want to print the contents of this file?", &
                  Information!, OkCancel!, 2)
   END IF

  //if the previous open channel failed
  IF ll_ddehandleword < 0 THEN
     ll_ddehandleword = OpenChannel("WinWord", "System" )
     IF ll_ddehandleword < 0 THEN
        RETURN -1
     END IF
  END IF

  IF li_msgbox = 1 THEN//if OK to print
    //try to open a channel to the word document first
    ll_ddehandledoc = OpenChannel("WinWord", ls_docname)
    IF ll_ddehandledoc < 0 THEN//if the open channel fails then the word document has to be opened
       lb_execremote_fileopen = TRUE

       //Send a FileOpen command to the Word application to open a document
       li_rc = ExecRemote("[FileOpen.Name =" + "~"" + ls_docname + "~"" + "]", ll_ddehandleword)
       IF li_rc < 0 THEN
          RETURN -1
       END IF

      //Open a channel to Word document and establish a warm link
      ll_ddehandledoc = OpenChannel("WinWord", ls_docname)
    
//    lecture des enreg de la dw

numcols = long(dw_emp_list.Object.DataWindow.Column.Count)
numrows = dw_emp_list.RowCount()

ll_compteur =  dw_emp_list.rowcount()

//string  ls_columns, ls_column, ls_wheres
//long  ll_rows, ll_index
//boolean bl_erreur = false
////Scan the columns datawindow and find all the selected columns. 
////Build a string of columns based on the selected rows.
//ll_rows = dw_columns.RowCount ( )
//
//
//sle_1.text =  is_table 
//  
//for li_step = 1 to ll_compteur
  for i = 1 to   ll_compteur
    //  IF ll_ddehandledoc = ll_rowcount then
        // ls_sd_id = Trim(dw_emp_list.GetItemnumber(i, "emp_id" ))
         ls_fname = dw_emp_list.GetItemString(i, "emp_fname" )
         ls_lname = dw_emp_list.GetItemString(i, "emp_lname" )
         ll_len = len(ls_lname)
         ls_lname = Left(ls_lname, 1) + Lower(Right(ls_lname, ll_len - 1))
         ls_street = ""
         //ls_street1 = dw_emp_list.GetItemString(i, "dept_id" )
       IF IsNull(ls_street1) = TRUE THEN
//            ls_street1 = ""
         END IF
//         ls_street2 = ads_seed_letter_info.GetItemString(i, "addr_2_txt" )
         IF IsNull(ls_street2) = TRUE THEN
//            ls_street2 = ""
         END IF
//         ls_street = ls_street1 + ls_street2
//         ls_city = ads_seed_letter_info.GetItemString(i, "cty_nm" )
//         ls_state = ads_seed_letter_info.GetItemString(i, "st_cd" )
//         ls_zip = ads_seed_letter_info.GetItemString(i, "zip_cd" )
//         ll_len = len(ls_zip)
         IF ll_len <= 6 THEN
            ls_zip = left(ls_zip, 5)
         ELSE
            ls_zip = left(ls_zip, 5) + '-' + right(ls_zip, ll_len - 5)
         END IF

         //Ask the DDE server application to accept data to be stored in the specified location
         li_rc = SetRemote("fname", ls_fname, ll_ddehandledoc)
         IF li_rc < 0 THEN
            lb_set_remote_ok = FALSE
         END IF

         IF lb_set_remote_ok = TRUE THEN
            li_rc = SetRemote("lname", ls_lname, ll_ddehandledoc)
            IF li_rc < 0 THEN
               lb_set_remote_ok = FALSE
            END IF
         END IF

         IF lb_set_remote_ok = TRUE THEN
            li_rc = SetRemote("street1", ls_street, ll_ddehandledoc)
            IF li_rc < 0 THEN
               lb_set_remote_ok = FALSE
            END IF
         END IF

         IF lb_set_remote_ok = TRUE THEN
            li_rc = SetRemote("city", ls_city, ll_ddehandledoc)
            IF li_rc < 0 THEN
               lb_set_remote_ok = FALSE
            END IF
         END IF

         IF lb_set_remote_ok = TRUE THEN
           li_rc = SetRemote("state", ls_state, ll_ddehandledoc)
           IF li_rc < 0 THEN
              lb_set_remote_ok = FALSE
           END IF
        END IF

        IF lb_set_remote_ok = TRUE THEN
           li_rc = SetRemote("zip", ls_zip, ll_ddehandledoc)
           IF li_rc < 0 THEN
              lb_set_remote_ok = FALSE
           END IF
        END IF

        IF lb_set_remote_ok = TRUE THEN
           li_rc = SetRemote("fname2", ls_fname, ll_ddehandledoc)
           IF li_rc < 0 THEN
              lb_set_remote_ok = FALSE
           END IF
        END IF

        IF lb_set_remote_ok = TRUE THEN
           IF ls_sd_id = "" THEN
              li_rc = SetRemote("sd_id", ls_sd_id, ll_ddehandledoc)
           END IF
        END IF

///envoyer ma datawindow sur 1 balise word



        //if setremotes were successful then only do we want to print the document and save it
        IF lb_set_remote_ok = TRUE THEN
           //Send a FilePrint command to the Word document to print the document
           li_rc = ExecRemote("[FilePrint]", ll_ddehandledoc)
           IF li_rc < 0 THEN
              RETURN -1
           END IF
        END IF
       // END IF
        i++
  next
      END IF

     //Send a FileSave command to the Word document to save the changes
     li_rc = ExecRemote("[FileSave]", ll_ddehandledoc)
     IF li_rc < 0 THEN
        RETURN -1
     END IF

     //closes the channel to the word document
     li_rc = CloseChannel(ll_ddehandledoc)
     IF li_rc < 0 THEN
        RETURN -1
     END IF

     IF lb_execremote_fileopen = TRUE THEN //if execremote  used to open the file then we have to close it
        //Send a single  FileClose command to the word DDE server application (cold link)
        li_rc = ExecRemote("[FileClose()]", "WinWord", ls_docname)
        IF li_rc < 0 THEN
           RETURN -1
        END IF
     END IF

 END IF//if OK to print
//
 //closes the channel to the Word application
 li_rc = CloseChannel(ll_ddehandleword)
 IF li_rc = 0 THEN//if 'Run' was used to start Word, we want to exit the Word application
    //Send a single  FileExit command to the word DDE server application (cold link)
     li_rc = ExecRemote("[FileExit()]", "WinWord", "System" )
     IF li_rc < 0 THEN
         RETURN -1
      END IF
   END IF
END IF//user opens a file

IF li_msgbox = 2 THEN
   RETURN 2
END IF

IF lb_set_remote_ok = FALSE THEN
   RETURN -1
END IF

RETURN 1

Hors ligne

 

Pied de page des forums

Propulsé par FluxBB 1.2.22