一、建议将
USE jsmd20190101 ALIAS jsmd IN 0
USE jsrkb20190101 ALIAS jsrkb IN 0
USE kb20190101 ALIAS rkb IN 0
放到表单的Load 事件
二、以下代码放到Tree控件的Click事件中:
IF !ISNULL(This.SelectedItem.Parent) &&当前节点为教师
mxm=ALLTRIM(This.Nodes(This.SelectedItem.Key).Text)
IF MESSAGEBOX("确要生成 "+mxm+" 任课表吗?",4+32+0,"确认:")=6
wjm="f:\temp2\grkbmb.doc"
SELECT jsmd
LOCATE FOR ALLTRIM(jsmd.姓名)==mxm
IF FOUND()
* mxm=ALLTRIM(node.text)
WAIT WINDOW '正在生成教师个人任课表...'+ mxm nowait
FileName="F:\temp3\"+mxm+"_任程表.doc"
COPY FILE (wjm) TO (FileName)
WordApp=CREATEOBJECT("Word.application")
* WordApp.Visible =.t.
WordTable=WordApp.Application.Documents.Open(FileName)
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(FileName)
WordApp.ActiveDocument.close
WAIT WINDOW mxm+' 任课表成生完成!'
ENDIF
ENDIF
ENDIF