Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

*
*Enable and show controls in the Data for New Document group box
set com(#gpbx_3 #labl_2) enabled(true)

execute infmessage 'A new document has been opened.'

*Update the list of documents
execute doclist

*disable the Add Document button until the employee information has been inserted
set #addbtn enabled(false)
ENDROUTINE

*Add employee information to the document
EVTROUTINE HANDLING(#ltvw_1.DoubleClick)
*Concatenate first name and surname to get #Fullname
Use BConcat (#GiveName #SurName) (#FullName)
*Locate the Word bookmark 'fullname' in the document
invoke method(#WordDoc.Bookmarks.item<'fullname'>.select)
*Insert the value of the #fullname field
invoke method(#WordApp.Selection.TypeText) text(#fullname)

invoke method(#WordDoc.Bookmarks.item<'address1'>.select)
invoke method(#WordApp.Selection.TypeText) text(#address1)

invoke method(#WordDoc.Bookmarks.item<'address2'>.select)
invoke method(#WordApp.Selection.TypeText) text(#address2)

invoke method(#WordDoc.Bookmarks.item<'address3'>.select)
invoke method(#WordApp.Selection.TypeText) text(#address3)

invoke method(#WordDoc.Bookmarks.item<'postcode'>.select)
use numeric_string #postcode #std_texts
invoke method(#WordApp.Selection.TypeText) text(#std_texts)

invoke method(#WordDoc.Bookmarks.item<'phonehme'>.select)
invoke method(#WordApp.Selection.TypeText) text(#phonehme)

invoke method(#WordDoc.Bookmarks.item<'phonebus'>.select)
invoke method(#WordApp.Selection.TypeText) text(#phonebus)

invoke method(#WordDoc.Bookmarks.item<'writernam'>.select)
invoke method(#WordApp.Selection.TypeText) text(#WordApp.UserName)

invoke method(#WordDoc.Bookmarks.item<'homepage'>.select)
invoke method(#WordApp.Selection.TypeText) text(www.lansa.com)

invoke method(#WordDoc.Bookmarks.item<'fulldate'>.select)
invoke method(#WordApp.Selection.TypeText) text(#datec)

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

invoke method(#WordDoc.Bookmarks.item<'skills'>.select)
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 empty row of the table
invoke method(#wordapp.selection.Rows.Delete)

*Enable and disable components
set com(#gpbx_4 #ltvw_2 #savebtn #closebtn #printbtn) enabled(true)
set com(#gpbx_3 #labl_2) enabled(false)
clr_list #ltvw_1
set #addbtn enabled(true)

execute infmessage 'Employee details have been added to document.'
ENDROUTINE

EVTROUTINE HANDLING(#LTVW_2.ItemGotFocus)
*activate the selected document
invoke method(#wordapp.documents.item<#std_text>.activate)

*set #ltvw_2.currentitem selected(true)
ENDROUTINE

EVTROUTINE HANDLING(#PRINTBTN.Click)
*Print out the document.
invoke method(#WordDoc.PrintOut)

*Alternative methods:
* invoke method(#WordApp.Dialogs.item<VA_WORD.wdDialogFilePrint>.show)
* invoke method(#WordApp.ActiveDocument.PrintOut)
execute infmessage 'Document has been sent to the printer.'
ENDROUTINE

EVTROUTINE HANDLING(#SAVEBTN.Click)
*Open the Save dialog
invoke method(#WordApp.Dialogs.item<VA_WORD.wdDialogFileSaveAs>.show)

*update document list
execute doclist
execute infmessage 'Document has been saved.'
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)
endif
execute doclist
execute infmessage 'Document has been closed.'
ENDROUTINE