@wengjl 谢谢!问题已解决。
一张纸打印二位老师的课表,节省了一半的纸张,环保。通过探索,多学了一点知识或者方法。从这些角度看是值的。换其他角度看并不一定值……哈……哈……哈……
SET TALK OFF SET SAFETY OFF CLOSE TABLES ALL CLEAR wjm=SYS(5)+SYS(2003)+"\grkbmb1.doc" WordApp=CREATEOBJECT("word.application") USE jsmd20180912 ALIAS jsmd20180912 IN 0 USE jsrkb20190101 ALIAS jsrkb20190101 IN 0 USE kb20190101 ALIAS kb20190101 IN 0 SELECT jsmd20180912 GOTO top rkmc="" Do While !Eof('jsmd20180912') xm=ALLTRIM(姓名) * rkmc[color=#808080]=xm+","[/color] kbxh=IIF(MOD(RECNO(),2)=0,2,1) IF kbxh=1 WordTable=WordApp.Application.Documents.Open(wjm) WordApp.Visible =.t. outfnm=xm ELSE outfnm=outfnm+'、'+xm ENDIF SELECT jsrkb20190101 krecc=RECCOUNT() FOR k=1 TO krecc SELECT jsrkb20190101 GO k FOR i=1 TO fcount() m=FIELD(i) xm2= &m. IF ALLTRIM(xm2)=ALLTRIM(xm) THEN &&IF ALLTRIM(xm2)=ALLTRIM(xm) 用完全匹配保险 * rkmc[color=#808080]=rkmc+FIELD(i)+nj+bj+','[/color] * zk( m,nj,bj) zk( m,nj,bj,kbxh) SELECT jsrkb20190101 &&保险起见,加这一句。调用过程与函数后,返回当前工作区。 ENDIF NEXT i ENDFOR =WORDAPP.Selection.homekey(6) WORDAPP.ActiveDocument.Content.Find.Execute('ABCDEF',.F.,.F.,.F.,.F.,.F.,.T.,.F.,.F.,'&xm',1) SELECT jsmd20180912 skip IF kbxh=2 OR EOF('jsmd20180912') oFile=SYS(5)+SYS(2003)+"\"+ALLTRIM(outfnm)+"_课程表.doc" WordApp.Documents(1).SaveAs(oFile) WordApp.ActiveDocument.Close endif ENDDO WORDAPP.quit WORDAPP=.NULL. CLOSE ALL QUIT PROCEDURE zk * LPARAMETERS kcm,lnj,lbj LPARAMETERS kcm,lnj,lbj,xh LOCAL j,zkm,xq,jc,zkkm wknb=SELECT(0) SELECT kb20190101 GOTO top LOCATE FOR ALLTRIM(nj)==ALLTRIM(lnj) AND ALLTRIM(bj)==ALLTRIM(lbj) &&如果不需要用==,可以用 LOCATE FOR nj=ALLTRIM(lnj) AND bj=ALLTRIM(lbj) 效率高一点点,但不建议这样 IF FOUND() FOR j=3 TO FCOUNT() zkm=FIELD(j) zkkm= &zkm. IF ALLTRIM(zkkm)=ALLTRIM(kcm) then xq=VAL(SUBSTR(zkm,5,1)) jc=VAL(SUBSTR(zkm,6,1)) scsz=ALLTRIM(nj)+ALLTRIM(bj)+ALLTRIM(kcm) WordTable.Tables(xh).Cell(jc+1,xq+2).Range.Text=scsz ENDIF NEXT j ENDIF ** SELECT kb20190101 本身没错但调用后的工作区变了。 SELECT (wknb) RETURN