下列程序有点问题,请高手指点!
下列程序有点问题,请高手指点,万分感谢!!!
CLEAR ALL
CLOSE ALL
SET TALK OFF
SET SAFETY OFF
SET DATE TO YMD
SET MARK TO "-"
SET CENTURY ON
SET COMPATIBLE OFF
cCurrentProcedure = SYS(16,1)
nPathStart = AT(":",cCurrentProcedure)- 1
nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart)
mypath=SUBSTR(cCurrentProcedure, nPathStart, nLenofPath)
SET Default TO (mypath)
wjm=mypath+"\bjkbmb3.doc" && 班级课程表模板(含有标题行的空表)
PUBLIC cnj,cbj,cxkmc,i
WordApp=CREATEOBJECT("Word.application")
WordApp.Visible =.t.
SELECT 0
USE jsrkb alia bjb
SCAN
cnj=bjb.nj
cbj=bjb.bj
WAIT WINDOW '正在生成“ '+cnj+cbj+' ”的日课表……' NOWAIT
SELECT * from rkzb201803 where nj=cnj and bj=cbj into table bjkb
SELECT bjkb
WordTable=WordApp.Application.Documents.Open(wjm) && 关键
wordapp.selection
wordapp.Selection.InsertAfter(ALLTRIM("&cnj&cbj")) && 在模板文件标题行插入年级、班级
SELECT bjkb
FOR i=1 TO 5
FOR j=1 TO 6
cxkmc=ALLTRIM(EVALUATE("bjkb."+"zhou"+TRANSFORM(i)+TRANSFORM(j)))
WordTable.Tables.item(1).cell(j*2,i+2).range.text=cxkmc
SELECT bjb
FOR k=1 TO FCOUNT("bjb")
IF FIELD(k)=cxkmc
WordTable.Tables.item(1).cell(j*2+1,i+2).range.text=EVALUATE(FIELD(k))
ENDIF
ENDFOR
ENDFOR
endfor
SELECT bjkb
USE
SELECT bjb
WAIT CLEAR
filename=mypath+"\"+cnj+cbj+"课程表.doc"
WordApp.ActiveDocument.PrintOut
WordApp.Documents(1).SaveAs(filename) &&自动保存文件
WordApp.ActiveDocument.Close
* SELECT bjkb
* USE
* SELECT bjb
* WAIT CLEAR
*ERASE bjkb.dbf
ENDSCAN
ERASE bjkb.dbf
wordapp.application.quit
MESSAGEBOX("班级日课表的word文档,生成完毕!",64,"提示:")
QUIT