源码:
https://bbs.bccn.net/thread-485653-2-1.html (16楼)
我纯手工打造,没有保存源码,将16楼朋友的源码中添加了写入word的代码,思路、源码均为16楼朋友的,希望能帮到你!
*|* 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
======================================
模板改了一下:
[此贴子已经被作者于2018-4-4 10:33编辑过]