回复 18楼 王咸美
我确实手动打造,没有保存源码,将楼上的代码添加了写入word的语句,就成为下面的程序,思路、源码均为楼上朋友的哈。
*|* test.prg
SET TALK OFF
SET SAFETY OFF
CLOSE ALL
CLEAR
wjm=SYS(5)+SYS(2003)+"\grkbmb.doc"
WordApp=CREATEOBJECT("Word.application")
USE jsmd ALIAS jsmd IN 0
USE jsrkb ALIAS jsrkb IN 0
USE rkzb201803 ALIAS rkzb201803 IN 0
SELECT jsmd
GOTO top
rkmc=""
SCAN
xm=ALLTRIM(姓名)
rkmc=xm+","
WordTable=WordApp.Application.Documents.Open(wjm)
WordApp.Visible =.t.
SELECT jsrkb
GOTO top
SCAN
FOR i=1 TO 18
m=FIELD(i)
xm2= &m.
IF ALLTRIM(xm2)=ALLTRIM(xm) then
rkmc=rkmc+FIELD(i)+nj+bj+','
zk( m,nj,bj)
ENDIF
NEXT i
ENDSCAN
WORDAPP.ActiveDocument.Content.Find.Execute('ABCDEF',.F.,.F.,.F.,.F.,.F.,.F.,.F.,.F.,'&xm',2)
oFile=SYS(5)+SYS(2003)+"\"+ALLTRIM(xm)+"_课程表.doc"
WordApp.Documents(1).SaveAs(oFile)
WordApp.ActiveDocument.Close
SELECT jsmd
ENDSCAN
WORDAPP.quit
WORDAPP=.NULL.
CLOSE ALL
QUIT
PROCEDURE zk
LPARAMETERS kcm,lnj,lbj
LOCAL j,zkm,xq,jc,zkkm
SELECT rkzb201803
GOTO top
LOCATE FOR ALLTRIM(nj)=ALLTRIM(lnj) AND ALLTRIM(bj)=ALLTRIM(lbj)
IF NOT EOF() THEN
FOR j=3 TO 32
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.item(1).Cell(jc+1,xq+2).Range.Text="&scsz"
ENDIF
NEXT j
ENDIF
SELECT jsrkb
RETURN
======================================
模板改了一下: