Products Downloads


French version


 

General example

 

* Editing in a Word document the personnel list by company

* Template: emplcomp-mod.doc in exploit\client\obj

* 2 bookmarks: compcod, compname

***

* Retrieving companies in memory list LST_COMP

LOAD_SQL_LST LST_COMP COMPANY *SORT(CO_COMPANY_CODE)

*

**** connecting to Word ****

* The WordRun parameter is set to *TRUE if Microsoft Word

* is already running; *FALSE in the opposite case.

* This parameter is useful to close (or not) the Microsoft Word

* application when the Visual Adelia application closes.

CALL_METHOD  CLI_WORD  App_Connect  WordRun ReturnCode

 

*** read loop for companies list

READ_LST LST_COMP

***

* For each company, their employees are retrieved in the

* memory list LST_EMPL

CLEAR_LST LST_EMPL

LOAD_SQL_LST LST_EMPL EMPLOYEE *COND(EM_COMPANY_CODE = :CO_COMPANY_CODE) -

*SORT(EM_COMPANY_CODE)

**** retrieving template emplcomp-tem.doc ****

FileName = 'D:\ exploit \client\obj\emplcomp-tem.doc'

CALL_METHOD  CLI_WORD  Doc_Open  FileName ReturnCode

**** creating a Word document different for every company ****

ww_empldoc = 'empl' // CO_COMPANY_CODE // '.doc'

FileName = 'D:\ exploit \client\obj\' // ww_empldoc

CALL_METHOD  CLI_WORD  Doc_Save_As  FileName ReturnCode

 

*** header information ***

SectionNbr = 1

Story = _WRD_MAIN_TEXT_STORY

CALL_METHOD  CLI_WORD  Rng_Set_Story  Story  SectionNbr  ReturnCode

* positioning on bookmark 'compcod'

EltNbr = 1

EltName = 'compcod'

Text = CO_COMPANY_CODE

Type = _WRD_GO_TO_BOOKMARK

MovementType = _WRD_GO_TO_ABSOLUTE

CALL_METHOD  CLI_WORD  Rng_Go_To  type MovementType  EltNbr EltName  ReturnCode

CALL_METHOD  CLI_WORD  Rng_Set_Text  Text  ReturnCode

 

* positioning on bookmark 'compname'

EltNbr = 2

EltName = 'compname'

Text = CO_COMPANY_NAME

Type = _WRD_GO_TO_BOOKMARK

MovementType = _WRD_GO_TO_ABSOLUTE

CALL_METHOD  CLI_WORD  Rng_Go_To  type  MovementType  EltNbr EltName  ReturnCode

CALL_METHOD  CLI_WORD  Rng_Set_Text  Text  ReturnCode

 

*** data in table ***

* the section must be set again before creating the line

SectionNbr = 1

Story = _WRD_MAIN_TEXT_STORY

CALL_METHOD  CLI_WORD  Rng_Set_Story  Story  SectionNbr  ReturnCode

 

* Starting to load table from line 2 below header

ww_i = 2

**** employee list loop ****

READ_F_ELT LST_EMPL

DO_WHILE &CODE_LST(LST_EMPL) = *NORMAL

*** data in table: feeding lines/columns ***

* lines below header. Line n° = ww_i

Position = ww_i

CALL_METHOD  CLI_WORD  Row_Add  Position  ReturnCode

 

* column 1: employee name

RowNumber = ww_i

ColumnNumber = 1

FormatNum = *BLANK

Text = EM_EMPLOYEE_NAME

CALL_METHOD  CLI_WORD  Cel_Set_Value  RowNumber  ColumnNumber  Text  -

FormatNum ReturnCode

 

* column 2: first name

ColumnNumber = 2

NumFormat  = *BLANK

Text = EM_EMPLOYEE_FNAME

CALL_METHOD  CLI_WORD  Cel_Set_Value  RowNumber  ColumnNumber  Text  -

NumFormat ReturnCode

 

* column 3: Town

ColumnNumber = 3

NumFormat = *BLANK

Text = EM_EMPLOYEE_TOWN

CALL_METHOD  CLI_WORD  Cel_Set_Value  RowNumber  ColumnNumber  Text  -

NumFormat  ReturnCode

 

ww_i = ww_i + 1

 

READ_NX_ELT LST_EMPL

*** end employees loop ***

REDO

 

*** printing document ***

FromPage = 1

ToPage = _WRD_ALL_PAGES

NbCopies = 1

CALL_METHOD  CLI_WORD  Doc_Print_Out  FromPage  ToPage  NbCopies  -

ReturnCode

 

*** closing current Word document ***

SaveChanges  = *TRUE

CALL_METHOD  CLI_WORD  Doc_Close  SaveChanges  ReturnCode

 

*** end of company loop ***

END_READ_LST

 

Back

 

 

↑ Top of page


  • Aucune étiquette