OleControl1的NodeClick代码作如下修改,点击 TREEVIEW控件中的姓名可生成个人任课表
*** ActiveX 控件事件 ***
LPARAMETERS node
CLOSE DATABASES
wjm="f:\temp2\grkbmb.doc"
PUBLIC k,mxm,cxkmc,i,j
WordApp=CREATEOBJECT("Word.application")
WordApp.visible=.t.
USE jsmd20190101 ALIAS jsmd IN 0
USE jsrkb20190101 ALIAS jsrkb IN 0
USE kb20190101 ALIAS rkb IN 0
SELECT jsmd
LOCATE FOR ALLTRIM(jsmd.姓名)==ALLTRIM(node.text)
IF FOUND()
mxm=ALLTRIM(node.text)
WAIT WINDOW '正在生成教师个人任课表...'+ mxm nowait
WordTable=WordApp.Application.Documents.Open(wjm)
WordApp.Visible =.t.
WORDAPP.ActiveDocument.Content.Find.Execute('ABCDEF',.F.,.F.,.F.,.F.,.F.,.F.,.F.,.F.,'&mxm',2)
SELECT rkb
SCAN
cnj=rkb.nj
cbj=rkb.bj
FOR i=1 TO 5
FOR j=1 TO 6
cxkmc=ALLTRIM(EVALUATE("rkb."+"zhou"+TRANSFORM(i)+TRANSFORM(j)))
SELECT jsrkb
SCAN
FOR k=1 TO FCOUNT('jsrkb')
IF FIELD(k)=cxkmc AND EVALUATE(FIELD(k))= mxm AND ALLTRIM(nj)=cnj AND ALLTRIM(bj)=cbj
wordTable.tables.item(1).cell(j+1,i+2).range.text=cnj+cbj+cxkmc
ENDIF
ENDFOR
ENDSCAN
ENDFOR
ENDFOR
ENDSCAN
WordApp.Documents(1).saveas("F:\temp3\"+mxm+"_任程表.doc")
WordApp.ActiveDocument.close
endif
WORDAPP.quit
WORDAPP=.NULL.
* CLOSE ALL
* QUIT