Form S_198FB: Word ActiveX Report Writer

LANSA

Form S_198FB: Word ActiveX Report Writer
* ===================================================================
*
* Component : S_198FB
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Word ActiveX Report Writer
*
* 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 CAPTION('Word ActiveX Report Writer') FORMPOSITION(ScreenCenter) HEIGHT(423) LEFT(294) TOP(129) WIDTH(523)
DEFINE_COM CLASS(#va_WORD.Application) NAME(#WordApp) REFERENCE(*DYNAMIC)

DEFINE_COM CLASS(#PRIM_PHBN) NAME(#STARTBTN) CAPTION('Start Word') DISPLAYPOSITION(1) HEIGHT(20) LEFT(16) PARENT(#GPBX_2) TABPOSITION(1) TOP(24) WIDTH(105)
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#PRINTBTN) CAPTION('Print...') DISPLAYPOSITION(1) ENABLED(False) HEIGHT(20) LEFT(16) PARENT(#GPBX_4) TABPOSITION(1) TOP(48) WIDTH(113)
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#SAVEBTN) CAPTION('Save...') DISPLAYPOSITION(3) ENABLED(False) HEIGHT(20) LEFT(16) PARENT(#GPBX_4) TABPOSITION(3) TOP(24) WIDTH(113)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Word WindowState') DISPLAYPOSITION(3) ENABLED(False) HEIGHT(81) LEFT(16) PARENT(#GPBX_2) TABPOSITION(3) TABSTOP(False) TOP(72) WIDTH(113)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_1) CAPTION('Minimized') DISPLAYPOSITION(1) ENABLED(False) LEFT(15) PARENT(#GPBX_1) TABPOSITION(1) TOP(14) WIDTH(82)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_2) BUTTONCHECKED(True) CAPTION('Normal') DISPLAYPOSITION(2) ENABLED(False) LEFT(16) PARENT(#GPBX_1) TABPOSITION(2) TOP(32) WIDTH(89)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_3) CAPTION('Maximized') DISPLAYPOSITION(3) ENABLED(False) LEFT(16) PARENT(#GPBX_1) TABPOSITION(3) TOP(50) WIDTH(81)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_2) CAPTION('Word Application') DISPLAYPOSITION(1) HEIGHT(193) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(4) WIDTH(137)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_4) CAPTION('Report') DISPLAYPOSITION(3) HEIGHT(105) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(260) WIDTH(145)
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#CLOSEBTN) CAPTION('Close') DISPLAYPOSITION(2) ENABLED(False) HEIGHT(20) LEFT(16) PARENT(#GPBX_4) TABPOSITION(2) TOP(72) WIDTH(113)
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#SHOWHIDEBTN) CAPTION('Show/Hide Word') DISPLAYPOSITION(2) ENABLED(False) HEIGHT(20) LEFT(16) PARENT(#GPBX_2) TABPOSITION(2) TOP(48) WIDTH(105)
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(4) HEIGHT(25) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(4) TOP(371) WIDTH(515)
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#EXITBTN) CAPTION('Exit Word') DISPLAYPOSITION(4) ENABLED(False) HEIGHT(20) LEFT(16) PARENT(#GPBX_2) TABPOSITION(4) TOP(160) WIDTH(105)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_3) CAPTION('Contents of the Report') DISPLAYPOSITION(2) HEIGHT(361) LEFT(144) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(4) WIDTH(369)
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#LTVW_1) DISPLAYPOSITION(9) ENABLED(False) FULLROWSELECT(True) HEIGHT(193) LEFT(16) PARENT(#GPBX_5) TABPOSITION(9) TOP(26) WIDTH(169)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) CAPTION('First Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#LTVW_1) SOURCE(#GIVENAME) WIDTH(49)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_2) CAPTION('Surname') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#LTVW_1) SOURCE(#SURNAME) WIDTH(79) WIDTHTYPE(Remainder)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_1) BUTTONSTATE(Checked) CAPTION('Address') DISPLAYPOSITION(8) ENABLED(False) HEIGHT(19) LEFT(200) PARENT(#GPBX_5) TABPOSITION(8) TOP(32) WIDTH(89)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_2) BUTTONSTATE(Checked) CAPTION('Home Telephone') DISPLAYPOSITION(7) ENABLED(False) HEIGHT(20) LEFT(200) PARENT(#GPBX_5) TABPOSITION(7) TOP(56) WIDTH(121)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_3) BUTTONSTATE(Checked) CAPTION('Business Telephone') DISPLAYPOSITION(6) ENABLED(False) HEIGHT(20) LEFT(200) PARENT(#GPBX_5) TABPOSITION(6) TOP(80) WIDTH(121)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_4) BUTTONSTATE(Checked) CAPTION('Start and End Dates') DISPLAYPOSITION(5) ENABLED(False) HEIGHT(20) LEFT(200) PARENT(#GPBX_5) TABPOSITION(5) TOP(104) WIDTH(129)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_5) BUTTONSTATE(Checked) CAPTION('Department and Section') DISPLAYPOSITION(3) ENABLED(False) HEIGHT(20) LEFT(200) PARENT(#GPBX_5) TABPOSITION(3) TOP(128) WIDTH(137)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_6) BUTTONSTATE(Checked) CAPTION('Salary') DISPLAYPOSITION(2) ENABLED(False) HEIGHT(20) LEFT(200) PARENT(#GPBX_5) TABPOSITION(2) TOP(152) WIDTH(81)
DEFINE_COM CLASS(#PRIM_LABL) NAME(#LABL_1) CAPTION('Hold down Ctrl key to select more than one employee') DISPLAYPOSITION(1) HEIGHT(14) LEFT(16) PARENT(#GPBX_5) TABPOSITION(1) TABSTOP(False) TOP(8) WIDTH(297)
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#CREATEBTN) CAPTION('Create Report') DISPLAYPOSITION(1) HEIGHT(20) LEFT(232) PARENT(#GPBX_3) TABPOSITION(1) TOP(328) WIDTH(120)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_7) BUTTONSTATE(Checked) CAPTION('Skills') DISPLAYPOSITION(4) ENABLED(False) HEIGHT(20) LEFT(200) PARENT(#GPBX_5) TABPOSITION(4) TOP(176) WIDTH(73)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_8) CAPTION('Page break between employees') DISPLAYPOSITION(2) ENABLED(False) HEIGHT(20) LEFT(136) PARENT(#GPBX_3) TABPOSITION(2) TOP(252) WIDTH(177)
DEFINE_COM CLASS(#S_198RH.Visual) NAME(#S_198RH) DISPLAYPOSITION(4) ENABLED(False) HEIGHT(19) LEFT(16) MARGINLEFT(80) PARENT(#GPBX_3) TABPOSITION(4) TOP(276) WIDTH(300)
DEFINE_COM CLASS(#S_198RF.Visual) NAME(#S_198RF) DISPLAYPOSITION(6) ENABLED(False) HEIGHT(19) LEFT(16) MARGINLEFT(80) PARENT(#GPBX_3) TABPOSITION(6) TOP(300) WIDTH(300)
DEFINE_COM CLASS(#PRIM_CKBX) NAME(#CKBX_9) CAPTION('Page Numbers') DISPLAYPOSITION(3) ENABLED(False) HEIGHT(20) LEFT(16) PARENT(#GPBX_3) TABPOSITION(3) TOP(252) WIDTH(89)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_5) DISPLAYPOSITION(5) HEIGHT(230) LEFT(16) PARENT(#GPBX_3) TABPOSITION(5) TABSTOP(False) TOP(16) WIDTH(345)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_3) PARENT(#LTVW_1) SOURCE(#EMPNO) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_4) PARENT(#LTVW_1) SOURCE(#ADDRESS1) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_5) PARENT(#LTVW_1) SOURCE(#ADDRESS2) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_6) PARENT(#LTVW_1) SOURCE(#ADDRESS3) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_7) PARENT(#LTVW_1) SOURCE(#POSTCODE) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_8) PARENT(#LTVW_1) SOURCE(#PHONEHME) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_9) PARENT(#LTVW_1) SOURCE(#PHONEBUS) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_10) PARENT(#LTVW_1) SOURCE(#STARTDTER) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_11) PARENT(#LTVW_1) SOURCE(#TERMDATER) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_12) PARENT(#LTVW_1) SOURCE(#DEPTMENT) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_13) PARENT(#LTVW_1) SOURCE(#SECTION) VISIBLE(False) WIDTH(20)
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_14) PARENT(#LTVW_1) SOURCE(#SALARY) VISIBLE(False) WIDTH(20)

*working list for skills
Def_list name(#skills) fields(#skilcode #SkilDesc #dateacqr #grade #comment #dateacq #gradedes) type(*working) Entrys(9999)

* Define a component definition for fiedl #I so that it's value property can be used as index in collections

EVTROUTINE HANDLING(#COM_OWNER.Initialize) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS)
*disable controls
execute disable10
* set #STD_BOOL to False because Word is not visible
change #STD_BOOL False
ENDROUTINE

EVTROUTINE HANDLING(#STARTBTN.Click)
*Start Word by setting a reference to it. Word has been enrolled as ActiveX component S_WORD
SET_REF COM(#WordApp) TO(*CREATE_AS #va_word.application)

*Add employee information to #ltvW_1
select fields(*all) from_file(pslmst)
add_entry #ltvw_1
endselect

*If Word has been started, enable some controls and issue a message
if_ref com(#wordapp) is_not(*null)
execute enable10
execute infmessage 'Word has been started.'
endif

*enable controls
execute enable10
ENDROUTINE

EVTROUTINE HANDLING(#showhidebtn.Click)
*If Word is hidden make it visible and vice versa
if cond('#wordapp.visible *eq True')
change #STD_BOOL False
SET #WordApp Visible(false)
else
SET #WordApp Visible(true)
change #STD_BOOL True
endif
ENDROUTINE

EVTROUTINE HANDLING(#RDBN_1.Click)
*Set the size of the Word window using the Windowstate property of the Word application object.
IF COND('#rdbn_1.buttonchecked *eq true')
SET #WordApp Windowstate(va_WORD.wdWindowStateMinimize)
endif
ENDROUTINE

EVTROUTINE HANDLING(#RDBN_2.Click)
*Set the size of the Word window using the Windowstate property of the Word application object.
if cond('#rDbn_2.buttonchecked *eq True')
SET #WordApp Windowstate(va_WORD.wdWindowStateNormal)
endif
ENDROUTINE

EVTROUTINE HANDLING(#RDBN_3.Click)
*Set the size of the Word window using the Windowstate property of the Word application object.
if cond('#rdbn_3.buttonchecked *eq True')
SET #WordApp Windowstate(va_WORD.wdWindowStateMaximize)
endif
ENDROUTINE

EVTROUTINE HANDLING(#EXITBTN.Click)
* Close Word without saving any changes
invoke method(#WordApp.Quit) savechanges(0)
*
*issue a message and disable controls
execute infmessage 'Word has been closed.'
execute disable10
ENDROUTINE

* Create the contents of the report
EVTROUTINE HANDLING(#CreateBtn.Click)
* add a new document
invoke method(#wordapp.documents.add)
* create a report for all selected employees
SELECTLIST NAMED(#LTVW_1)
if '#LTVW_1.CurrentItem.Selected = TRUE'
* Set the font size to 14 bold and type in employee name, then change the font to 12, not bold
set com(#WordApp.Selection.font) size(14)
set com(#WordApp.Selection.font) bold(1)
invoke method(#WordApp.Selection.TypeText) text('Employee ')
invoke method(#WordApp.Selection.TypeText) text(#givename)
invoke method(#WordApp.Selection.TypeText) text(' ')
invoke method(#WordApp.Selection.TypeText) text(#surname)
set com(#WordApp.Selection.font) size(12)
set com(#WordApp.Selection.font) bold(0)

*add a table
invoke method(#WordApp.ActiveDocument.Tables.Add) Range(#WordApp.Selection.Range) NumRows(1) NumColumns(1)

* If the Address check box is ticked, type in the address details
if cond('#ckbx_1.ButtonState *eq Checked')
invoke method(#WordApp.Selection.TypeText) text(#Address1)
invoke method(#WordApp.Selection.TypeText) text(' ')

invoke method(#WordApp.Selection.TypeText) text(#Address2)
invoke method(#WordApp.Selection.TypeText) text(' ')

invoke method(#WordApp.Selection.TypeText) text(#Address3)
invoke method(#WordApp.Selection.TypeText) text(' ')

DEFINE #PostcodeC Type(*char) Length(6)
use builtin(numeric_string) with_args(#Postcode) to_get(#PostcodeC)
invoke method(#WordApp.Selection.TypeText) text(#PostcodeC)

invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
endif

*If the Home Telephone check box is ticked, type in the number
if cond('#ckbx_2.ButtonState *eq Checked')
invoke method(#WordApp.Selection.TypeText) text('Home Telephone: ')
invoke method(#WordApp.Selection.TypeText) text(#Phonehme)

invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
endif

*If the Business Telephone check box is ticked, type in the number
if cond('#ckbx_3.ButtonState *eq Checked')
invoke method(#WordApp.Selection.TypeText) text('Business Telephone: ')
invoke method(#WordApp.Selection.TypeText) text(#PhoneBus)

invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
endif

* If the Start and End Dates check box h as been ticked, type in the dates
if cond('#ckbx_4.ButtonState *eq Checked')
DEFINE #StartDatC Type(*char) Length(6)
DEFINE #TermDatC Type(*char) Length(6)
use builtin(numeric_string) with_args(#Startdter) to_get(#StartdatC)
use builtin(numeric_string) with_args(#Termdater) to_get(#TermdatC)

invoke method(#WordApp.Selection.TypeText) text('Start Date: ')
invoke method(#WordApp.Selection.TypeText) text(#StartdatC)
invoke method(#WordApp.Selection.TypeText) text(' End Date: ')
invoke method(#WordApp.Selection.TypeText) text(#TermDatC)

invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
endif

*If the Department and Section check box has been ticked, type them in
if cond('#ckbx_5.ButtonState *eq Checked')
invoke method(#WordApp.Selection.TypeText) text('Department: ')
invoke method(#WordApp.Selection.TypeText) text(#Deptment)
invoke method(#WordApp.Selection.TypeText) text(' Section: ')
invoke method(#WordApp.Selection.TypeText) text(#Section)

invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
endif

*if the Salary check box has been ticked, type it in
if cond('#ckbx_6.ButtonState *eq Checked')
DEFINE #SalaryC Type(*char) Length(30)
invoke method(#WordApp.Selection.TypeText) text('Salary: ')
use builtin(numeric_string) with_args(#Salary) to_get(#SalaryC)
invoke method(#WordApp.Selection.TypeText) text(#SalaryC)

invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
endif
* Delete the last blank row of the table
invoke method(#wordapp.selection.rows.delete)

* If the Skills check box has been ticked, type in the skills information
if cond('#ckbx_7.ButtonState *eq Checked')
* Add blank lines, heading and a table
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#WordApp.Selection.InsertParagraph)
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#WordApp.Selection.InsertParagraph)
set com(#WordApp.Selection.font) bold(1)
invoke method(#WordApp.Selection.TypeText) text('Skills')
set com(#WordApp.Selection.font) size(10)
invoke method(#WordApp.ActiveDocument.Tables.Add) Range(#WordApp.Selection.Range) NumRows(1) NumColumns(4)

* Create a header row for the table
invoke method(#WordApp.Selection.TypeText) text('Skill Code')
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#WordApp.Selection.TypeText) text('Description')
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#WordApp.Selection.TypeText) text('Grade')
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#WordApp.Selection.TypeText) text('Comments')
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#wordApp.Selection.InsertRows)
set com(#WordApp.Selection.font) bold(0)

*Get the skills information for the employee and add it to the working list #skills
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

Selectlist #skills
*Insert the value of the #skilcode field
invoke method(#WordApp.Selection.TypeText) text(#skilcode)
*Move cursor right to the next table cell
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)

invoke method(#WordApp.Selection.TypeText) text(#skildesc)
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)

invoke method(#WordApp.Selection.TypeText) text(#grade)
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)

invoke method(#WordApp.Selection.TypeText) text(#comment)
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)

*Add a new row to the table
invoke method(#wordapp.Selection.InsertRows)
endselect
* Delete the last row and add a blank line
invoke method(#wordapp.selection.rows.delete)
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
invoke method(#WordApp.Selection.InsertParagraph)
invoke method(#wordapp.Selection.MoveRight) Unit(1) Count(1)
endif

if cond('#ckbx_8.ButtonState *eq Checked')
* Insert a page break. To get the break types for Word, use F2 and view the values for WdBreakType
invoke method(#wordapp.selection.InsertBreak) Type(7)
endif

if cond('#ckbx_9.ButtonState *eq Checked')
* Insert page numbers. Note that you must use the ITEM keyword, <> signs and qualify the constant
* with the class name S_Word
invoke method(#WordApp.ActiveDocument.Sections.item<1>.Headers.item<va_Word.wdHeaderFooterPrimary>.PageNumbers.Add)
endif
endif
endselect
execute infmessage 'Report has been created.'

* Create the report header
invoke method(#WordApp.ActiveDocument.Sections.item<1>.Headers.item<va_Word.wdHeaderFooterPrimary>.Range.InsertAfter) Text(#S_198RH)
set com(#WordApp.ActiveDocument.Sections.item<1>.Headers.item<va_Word.wdHeaderFooterPrimary>.Range.Paragraphs) Alignment(va_Word.wdAlignParagraphCenter)

*Create the report footer
invoke method(#WordApp.ActiveDocument.Sections.item<1>.Footers.item<va_Word.wdHeaderFooterPrimary>.Range.InsertAfter) Text(#S_198RF)
set com(#WordApp.ActiveDocument.Sections.item<1>.Footers.item<va_Word.wdHeaderFooterPrimary>.Range.Paragraphs) Alignment(va_Word.wdAlignParagraphCenter)

*Go to the start of the page and show the report in print layout view
invoke method(#WordApp.Selection.HomeKey) Unit(6)
set com(#WordApp.ActiveWindow.View) Type(va_Word.wdPrintView)

* enable buttons
Execute enable20
ENDROUTINE

EVTROUTINE HANDLING(#PRINTBTN.Click)
*Print out the document. Note that you must use the ITEM keyword, <> signs and qualify the constant
* with the class name S_Word
invoke method(#WordApp.Dialogs.item<va_Word.wdDialogFilePrint>.show) SHOW_Retval(#std_num)
if cond('#std_num *ne 0')
execute infmessage 'Document has been sent to the printer.'
endif
execute ShowHide
ENDROUTINE

EVTROUTINE HANDLING(#SAVEBTN.Click)
* Bring up the Save dialog. Note that you must use the ITEM keyword, <> signs and qualify the constant
* with the class name S_Word
invoke method(#WordApp.Dialogs.item<va_Word.wdDialogFileSaveAs>.show) SHOW_Retval(#std_num)
if cond('#std_num *ne 0')
execute infmessage 'Document has been saved.'
endif
execute ShowHide
ENDROUTINE

EVTROUTINE HANDLING(#CLOSEBTN.Click)
*if a document is open, close it without saving any changes
if cond('#WordApp.Documents.Count *gt 0')
invoke method(#wordapp.activedocument.close) savechanges(0)
execute infmessage 'Document has been closed.'
else
execute infmessage 'No documents are open.'
endif
ENDROUTINE

* Enable controls
subroutine name(Enable10)
set com(#exitbtn #rdbn_1 #rdbn_2 #rdbn_3 #showhidebtn ) enabled(true)
set com(#ckbx_8 #ckbx_9 #ckbx_1 #ckbx_2 #ckbx_3 #ckbx_4 #ckbx_5 #ckbx_5 #ckbx_6 #ckbx_7 #labl_1) enabled(true)
set com(#ltvw_1 #createbtn #S_198RF #S_198RH) enabled(true)
endroutine

* Disable controls
subroutine name(Disable10)
clr_list (#ltvw_1)
set com(#exitbtn #rdbn_1 #rdbn_2 #rdbn_3 #showhidebtn ) enabled(false)
set com(#ckbx_8 #ckbx_9 #ckbx_1 #ckbx_2 #ckbx_3 #ckbx_4 #ckbx_5 #ckbx_5 #ckbx_6 #ckbx_7 #labl_1) enabled(false)
set com(#ltvw_1 #createbtn #S_198RF #S_198RH) enabled(false)
endroutine

subroutine name(Enable20)
set com(#CloseBtn #PrintBtn #SaveBtn) enabled(true)
endroutine

subroutine name(Disable20)
set com(#CloseBtn #PrintBtn #SaveBtn) enabled(false)
endroutine

subroutine ShowHide
*Make sure Word is visible/hidden
if cond('#std_bool *eq True')
SET #WordApp Visible(True)
else
SET #WordApp Visible(False)
endif
endroutine

* Information Message created by template VL_BBSTSBR
SUBROUTINE INFMESSAGE ((#EX_TEXT *RECEIVED))
define #ex_text *char 132
message msgid(dcm9993) msgf(dc@m01) msgdta(#ex_text *blanks)
ENDROUTINE
END_COM