Form VL_SAM093: MS Word Integration for Documents and Emails
* ===================================================================
*
* Component : VL_SAM093
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Using MS Word to produce Documents and E-mails
* The following RDMLX form is used to demonstrate how MS Word can be used
* from Visual LANSA applications.
*
* Disclaimer : The following material is supplied as sample material
* only. No warranty concerning this material or its use
* in any way whatsoever is expressed or implied.
*
* ===================================================================
FUNCTION OPTIONS(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Caption('MS Word - Standard Letter Examples') Formposition(ScreenCenter) Height(534) Layoutmanager(#ATLM_1) Left(553) Top(105) Width(322)
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Left) Marginbottom(3) Marginleft(3) Marginright(3) Margintop(3) Parent(#ATLM_1)
Define_Com Class(#PRIM_LTVW) Name(#LTVW_1) Displayposition(3) Height(341) Left(0) Parent(#COM_OWNER) Popupmenu(#PMNU_1) Selectionstyle(Single) Tabposition(2) Top(132) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_2) Attachment(Center) Manage(#LTVW_1) Parent(#ATLM_1)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Caption('Number') Captiontype(Caption) Displayposition(1) Parent(#LTVW_1) Source(#EMPNO) Width(18)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#LTVW_1) Source(#GIVENAME) Width(40)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_3) Displayposition(3) Parent(#LTVW_1) Source(#SURNAME) Width(20) Widthtype(Remainder)
Define_Com Class(#PRIM_PMNU) Name(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_BLANK) Caption('&Blank Letter') Displayposition(1) Parent(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_SALARY) Caption('&Salary Increase Letter') Displayposition(2) Parent(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_SKILLS) Caption('S&kills Confirmation Letter ') Displayposition(3) Parent(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_LIST) Caption('&Telephone List') Displayposition(4) Parent(#PMNU_1)
Define_Com Class(#VL_SAM092) Name(#MSWORD) Displayposition(4) Left(16) Parent(#COM_OWNER) Tabstop(False) Top(8) Visible(False)
Define_Com Class(#STD_TEXT.Visual) Name(#WRITERNAM) Caption('Letters are to be signed by ') Displayposition(2) Height(19) Labeltype(Caption) Marginleft(128) Parent(#COM_OWNER) Tabposition(3) Top(113) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_3) Attachment(Top) Manage(#WRITERNAM) Parent(#ATLM_1)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_4) Parent(#LTVW_1) Source(#STD_BOOL) Visible(False) Width(20)
Define_Com Class(#PRIM_GPBX) Name(#GPBX_1) Caption('Letter Options') Displayposition(1) Height(113) Left(0) Parent(#COM_OWNER) Tabposition(4) Tabstop(False) Top(0) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_4) Attachment(Top) Manage(#GPBX_1) Parent(#ATLM_1)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_1) Buttonchecked(True) Caption('Prepare Letter then allow Review and Print via MS Word') Displayposition(2) Left(16) Parent(#GPBX_1) Tabposition(1) Top(14) Width(289)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_2) Caption('Prepare and Print Letter then allow Review via MS Word ') Displayposition(1) Left(16) Parent(#GPBX_1) Tabposition(2) Top(37) Width(289)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_3) Caption('Prepare and Print Letter then Discard') Displayposition(3) Left(16) Parent(#GPBX_1) Tabposition(3) Top(60) Width(201)
Define_Com Class(#PRIM_PANL) Name(#PANL_1) Displayposition(5) Height(34) Layoutmanager(#FWLM_1) Left(0) Parent(#COM_OWNER) Tabposition(5) Tabstop(False) Top(473) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_5) Attachment(Bottom) Manage(#PANL_1) Parent(#ATLM_1)
Define_Com Class(#PRIM_TIMR) Name(#TIMER) Interval(0)
Define_Com Class(#PRIM_FWLM) Name(#FWLM_1) Flowoperation(Center) Flowoperationhor(Spread)
Define_Com Class(#PRIM_PHBN) Name(#BTN_MIN) Caption('Minimize MS Word') Displayposition(1) Enabled(False) Left(21) Parent(#PANL_1) Tabposition(1) Top(4) Width(120)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_1) Manage(#BTN_MIN) Parent(#FWLM_1)
Define_Com Class(#PRIM_PHBN) Name(#BTN_SHOW) Caption('Show MS Word') Displayposition(2) Enabled(False) Left(172) Parent(#PANL_1) Tabposition(2) Top(4) Width(120)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_2) Manage(#BTN_SHOW) Parent(#FWLM_1)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_4) Caption('Prepare and E-Mail Letter and then Discard ') Displayposition(4) Left(16) Parent(#GPBX_1) Tabposition(4) Top(83) Width(233)
Define #FullDate *Char 20 Desc('Full Date')
Def_list name(#skills) fields(#skilcode #SkilDesc #dateacqr #grade #comment #dateacq #gradedes) type(*working) Entrys(9999)
Def_Cond *ReviewDoc '(#RdBn_1.ButtonChecked = True) or (#RdBn_2.ButtonChecked = True)'
Def_Cond *PrintDoc '(#RdBn_2.ButtonChecked = True) or (#RdBn_3.ButtonChecked = True)'
Def_Cond *EmailDoc '(#RdBn_4.ButtonChecked = True)'
Def_Cond *KillDoc '(#RdBn_3.ButtonChecked = True) or (#RdBn_4.ButtonChecked = True) '
EVTROUTINE handling(#com_owner.Initialize)
Select (#EmpNo #GiveName #SurName) From_File(PslMst)
Change #Std_Bool False
Check_For In_File(PslSkl) With_Key(#EmpNo)
If_Status *EqualKey
Change #Std_Bool True
Endif
Add_entry #LtVw_1
EndSelect
Set #WriterNam Value('John and Mary Doe')
Set #Timer Interval(2000)
ENDROUTINE
EVTROUTINE HANDLING(#LET_BLANK.Click)
Execute GetEmploy
Invoke #MsWord.NewDoc Template(VL_SAM094)
Invoke #MsWord.InsertValues FromFields('writernam, fulldate, fullname, address1, address2, address3, postcode, givename')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#LET_SALARY.Click)
Execute GetEmploy
Invoke #MsWord.NewDoc Template(VL_SAM095)
Invoke #MsWord.InsertValues FromFields('writernam, mnthsal, salary, fulldate, fullname, address1, address2, address3, postcode, givename')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#LET_SKILLS.Click)
Execute GetEmploy
Execute GetSkills
Invoke #MsWord.NewDoc Template(VL_SAM096)
Invoke #MsWord.InsertValues FromFields('writernam, fulldate, fullname, address1, address2, address3, postcode, givename')
Invoke #MsWord.InsertTable FromList(Skills) FromFields('Skilcode, skildesc,grade,comment ')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#LET_LIST.Click)
Def_List #Employees (#Empno #SurName #GiveName #PhoneHme #Phonebus ) Type(*working) Entrys(9999)
Use Convertdate (*Datec a q) (#FullDate)
Clr_List #Employees
Select *All From_File(PslMst)
Add_Entry #Employees
EndSelect
Sort_List #Employees (#Surname #GiveName)
Invoke #MsWord.NewDoc Template(VL_SAM097)
Invoke #MsWord.MinimizeForm
Invoke #MsWord.InsertValues FromFields('writernam, fulldate')
Invoke #MsWord.InsertTable FromList(Employees) FromFields('surname,givename,empno,phonebus,phonehme ')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#Com_Owner.Closing)
Invoke #MSWord.CloseAllDoc Option(Discard)
Invoke #MSWord.CloseWord
ENDROUTINE
Subroutine GetEmploy
Fetch *all From_File(PslMst) With_Key(#EmpNo)
Use BConcat (#GiveName #SurName) (#FullName)
Use Convertdate (*Datec a q) (#FullDate)
EndRoutine
Subroutine Complete
if *PrintDoc
Invoke #MSWord.PrintDoc
Endif
if *ReviewDoc
Invoke #MSWord.RestoreForm
Invoke #MSWord.ShowForm
Endif
if *EmailDoc
Invoke #MSWord.SendMailDoc
Endif
If *KillDoc
Invoke #MSWord.CloseDoc Option(Discard)
Endif
EndRoutine
Subroutine GetSkills
Clr_List #Skills
Select *all From_File(PslSkl) with_Key(#Empno)
Fetch #SkilDesc from_File(SklTab) With_Key(#SkilCode) Keep_Last(50)
Add_Entry #Skills
EndSelect
EndRoutine
EVTROUTINE HANDLING(#LTVW_1.ItemGotSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS)
Set #Let_Skills Enabled(#Std_Bool)
ENDROUTINE
EVTROUTINE HANDLING(#BTN_MIN.Click)
Invoke #MSWord.MinimizeForm
ENDROUTINE
EVTROUTINE HANDLING(#BTN_SHOW.Click)
Invoke #MSWord.RestoreForm
Invoke #MSWord.ShowForm
ENDROUTINE
EVTROUTINE HANDLING(#TIMER.Tick) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS)
If '#MSWord.Connected = true'
Set (#Btn_Min #Btn_Show) Enabled(True)
Else
Set (#Btn_Min #Btn_Show) Enabled(False)
Endif
ENDROUTINE
END_COM
* ===================================================================
*
* Component : VL_SAM093
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Using MS Word to produce Documents and E-mails
* The following RDMLX form is used to demonstrate how MS Word can be used
* from Visual LANSA applications.
*
* Disclaimer : The following material is supplied as sample material
* only. No warranty concerning this material or its use
* in any way whatsoever is expressed or implied.
*
* ===================================================================
FUNCTION OPTIONS(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Caption('MS Word - Standard Letter Examples') Formposition(ScreenCenter) Height(534) Layoutmanager(#ATLM_1) Left(553) Top(105) Width(322)
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Left) Marginbottom(3) Marginleft(3) Marginright(3) Margintop(3) Parent(#ATLM_1)
Define_Com Class(#PRIM_LTVW) Name(#LTVW_1) Displayposition(3) Height(341) Left(0) Parent(#COM_OWNER) Popupmenu(#PMNU_1) Selectionstyle(Single) Tabposition(2) Top(132) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_2) Attachment(Center) Manage(#LTVW_1) Parent(#ATLM_1)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Caption('Number') Captiontype(Caption) Displayposition(1) Parent(#LTVW_1) Source(#EMPNO) Width(18)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#LTVW_1) Source(#GIVENAME) Width(40)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_3) Displayposition(3) Parent(#LTVW_1) Source(#SURNAME) Width(20) Widthtype(Remainder)
Define_Com Class(#PRIM_PMNU) Name(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_BLANK) Caption('&Blank Letter') Displayposition(1) Parent(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_SALARY) Caption('&Salary Increase Letter') Displayposition(2) Parent(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_SKILLS) Caption('S&kills Confirmation Letter ') Displayposition(3) Parent(#PMNU_1)
Define_Com Class(#PRIM_MITM) Name(#LET_LIST) Caption('&Telephone List') Displayposition(4) Parent(#PMNU_1)
Define_Com Class(#VL_SAM092) Name(#MSWORD) Displayposition(4) Left(16) Parent(#COM_OWNER) Tabstop(False) Top(8) Visible(False)
Define_Com Class(#STD_TEXT.Visual) Name(#WRITERNAM) Caption('Letters are to be signed by ') Displayposition(2) Height(19) Labeltype(Caption) Marginleft(128) Parent(#COM_OWNER) Tabposition(3) Top(113) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_3) Attachment(Top) Manage(#WRITERNAM) Parent(#ATLM_1)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_4) Parent(#LTVW_1) Source(#STD_BOOL) Visible(False) Width(20)
Define_Com Class(#PRIM_GPBX) Name(#GPBX_1) Caption('Letter Options') Displayposition(1) Height(113) Left(0) Parent(#COM_OWNER) Tabposition(4) Tabstop(False) Top(0) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_4) Attachment(Top) Manage(#GPBX_1) Parent(#ATLM_1)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_1) Buttonchecked(True) Caption('Prepare Letter then allow Review and Print via MS Word') Displayposition(2) Left(16) Parent(#GPBX_1) Tabposition(1) Top(14) Width(289)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_2) Caption('Prepare and Print Letter then allow Review via MS Word ') Displayposition(1) Left(16) Parent(#GPBX_1) Tabposition(2) Top(37) Width(289)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_3) Caption('Prepare and Print Letter then Discard') Displayposition(3) Left(16) Parent(#GPBX_1) Tabposition(3) Top(60) Width(201)
Define_Com Class(#PRIM_PANL) Name(#PANL_1) Displayposition(5) Height(34) Layoutmanager(#FWLM_1) Left(0) Parent(#COM_OWNER) Tabposition(5) Tabstop(False) Top(473) Width(314)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_5) Attachment(Bottom) Manage(#PANL_1) Parent(#ATLM_1)
Define_Com Class(#PRIM_TIMR) Name(#TIMER) Interval(0)
Define_Com Class(#PRIM_FWLM) Name(#FWLM_1) Flowoperation(Center) Flowoperationhor(Spread)
Define_Com Class(#PRIM_PHBN) Name(#BTN_MIN) Caption('Minimize MS Word') Displayposition(1) Enabled(False) Left(21) Parent(#PANL_1) Tabposition(1) Top(4) Width(120)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_1) Manage(#BTN_MIN) Parent(#FWLM_1)
Define_Com Class(#PRIM_PHBN) Name(#BTN_SHOW) Caption('Show MS Word') Displayposition(2) Enabled(False) Left(172) Parent(#PANL_1) Tabposition(2) Top(4) Width(120)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_2) Manage(#BTN_SHOW) Parent(#FWLM_1)
Define_Com Class(#PRIM_RDBN) Name(#RDBN_4) Caption('Prepare and E-Mail Letter and then Discard ') Displayposition(4) Left(16) Parent(#GPBX_1) Tabposition(4) Top(83) Width(233)
Define #FullDate *Char 20 Desc('Full Date')
Def_list name(#skills) fields(#skilcode #SkilDesc #dateacqr #grade #comment #dateacq #gradedes) type(*working) Entrys(9999)
Def_Cond *ReviewDoc '(#RdBn_1.ButtonChecked = True) or (#RdBn_2.ButtonChecked = True)'
Def_Cond *PrintDoc '(#RdBn_2.ButtonChecked = True) or (#RdBn_3.ButtonChecked = True)'
Def_Cond *EmailDoc '(#RdBn_4.ButtonChecked = True)'
Def_Cond *KillDoc '(#RdBn_3.ButtonChecked = True) or (#RdBn_4.ButtonChecked = True) '
EVTROUTINE handling(#com_owner.Initialize)
Select (#EmpNo #GiveName #SurName) From_File(PslMst)
Change #Std_Bool False
Check_For In_File(PslSkl) With_Key(#EmpNo)
If_Status *EqualKey
Change #Std_Bool True
Endif
Add_entry #LtVw_1
EndSelect
Set #WriterNam Value('John and Mary Doe')
Set #Timer Interval(2000)
ENDROUTINE
EVTROUTINE HANDLING(#LET_BLANK.Click)
Execute GetEmploy
Invoke #MsWord.NewDoc Template(VL_SAM094)
Invoke #MsWord.InsertValues FromFields('writernam, fulldate, fullname, address1, address2, address3, postcode, givename')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#LET_SALARY.Click)
Execute GetEmploy
Invoke #MsWord.NewDoc Template(VL_SAM095)
Invoke #MsWord.InsertValues FromFields('writernam, mnthsal, salary, fulldate, fullname, address1, address2, address3, postcode, givename')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#LET_SKILLS.Click)
Execute GetEmploy
Execute GetSkills
Invoke #MsWord.NewDoc Template(VL_SAM096)
Invoke #MsWord.InsertValues FromFields('writernam, fulldate, fullname, address1, address2, address3, postcode, givename')
Invoke #MsWord.InsertTable FromList(Skills) FromFields('Skilcode, skildesc,grade,comment ')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#LET_LIST.Click)
Def_List #Employees (#Empno #SurName #GiveName #PhoneHme #Phonebus ) Type(*working) Entrys(9999)
Use Convertdate (*Datec a q) (#FullDate)
Clr_List #Employees
Select *All From_File(PslMst)
Add_Entry #Employees
EndSelect
Sort_List #Employees (#Surname #GiveName)
Invoke #MsWord.NewDoc Template(VL_SAM097)
Invoke #MsWord.MinimizeForm
Invoke #MsWord.InsertValues FromFields('writernam, fulldate')
Invoke #MsWord.InsertTable FromList(Employees) FromFields('surname,givename,empno,phonebus,phonehme ')
Execute Complete
ENDROUTINE
EVTROUTINE HANDLING(#Com_Owner.Closing)
Invoke #MSWord.CloseAllDoc Option(Discard)
Invoke #MSWord.CloseWord
ENDROUTINE
Subroutine GetEmploy
Fetch *all From_File(PslMst) With_Key(#EmpNo)
Use BConcat (#GiveName #SurName) (#FullName)
Use Convertdate (*Datec a q) (#FullDate)
EndRoutine
Subroutine Complete
if *PrintDoc
Invoke #MSWord.PrintDoc
Endif
if *ReviewDoc
Invoke #MSWord.RestoreForm
Invoke #MSWord.ShowForm
Endif
if *EmailDoc
Invoke #MSWord.SendMailDoc
Endif
If *KillDoc
Invoke #MSWord.CloseDoc Option(Discard)
Endif
EndRoutine
Subroutine GetSkills
Clr_List #Skills
Select *all From_File(PslSkl) with_Key(#Empno)
Fetch #SkilDesc from_File(SklTab) With_Key(#SkilCode) Keep_Last(50)
Add_Entry #Skills
EndSelect
EndRoutine
EVTROUTINE HANDLING(#LTVW_1.ItemGotSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS)
Set #Let_Skills Enabled(#Std_Bool)
ENDROUTINE
EVTROUTINE HANDLING(#BTN_MIN.Click)
Invoke #MSWord.MinimizeForm
ENDROUTINE
EVTROUTINE HANDLING(#BTN_SHOW.Click)
Invoke #MSWord.RestoreForm
Invoke #MSWord.ShowForm
ENDROUTINE
EVTROUTINE HANDLING(#TIMER.Tick) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS)
If '#MSWord.Connected = true'
Set (#Btn_Min #Btn_Show) Enabled(True)
Else
Set (#Btn_Min #Btn_Show) Enabled(False)
Endif
ENDROUTINE
END_COM